nymea / nymea-app

A nymea frontend app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not edit event and condition in a saved magic

pop-ch opened this issue · comments

commented

I compose a magic involving a Lumi motion sensor (ZigBee). I save the magic and open it again for editing. It looks like this:

grafik

Clicking on the event (scBewegung - Presence) does not do anything.
Clicking on the condition (scBewegung: Light Intensity > 20) opens an empty condition editing pane. Neither the Thing nor the attribute are shown.
Clicking on the 2nd condition (phCuoluce: power = on) also opens an empty condition editing pane.
Deleting the first condition (scBewegung: Light Intensity > 20) also deletes the following 2nd condition.

The linked pull request fixes most of this:

Clicking on the event (scBewegung - Presence) does not do anything.

Fixed

Clicking on the condition (scBewegung: Light Intensity > 20) opens an empty condition editing pane. Neither the Thing nor the attribute are shown.

Fixed

Clicking on the 2nd condition (phCuoluce: power = on) also opens an empty condition editing pane.

Well, that actually is a feature... State evaluators are nested. A State evaluator has a condition, an operator (and|or) and a list of child evaluators. This way it's possible to form rather complex expressions like

When scBewegung: Presence detected AND (scBewegung: Light Intensity < 20 OR current time > 20:00)...

this would evaluate to active when scBewegung reports presence, provided it's less than 20 lx or later than 8pm.

In this case the first main evaluators condition is the presence detected, the operator is AND, and it has a single child, which in turn has a main condition of light intensity < 20, an operator of OR and a single child evaluator with a time condition on > 20:00.

Arguably it's not the most intuitive thing, but it's what has evolved after many iterations on how to implement this feature set on a touch friendly input mask...

Deleting the first condition (scBewegung: Light Intensity > 20) also deletes the following 2nd condition.

This, while not nice, is a direct outcome of the above... If you remove a state evaluator, it will remove the condition, the operator and all of its childs... Perhaps it could be improved by only removing the condition, moving the first childs condition into this one etc... Too complex for now, given that there are cases where it's rather impossible to know how to reorder the childs to still form a meaningful expression...