Make blockly Else if to an actual else if

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
ash77
Posts: 12
Joined: Wednesday 10 June 2015 22:10
Target OS: Windows
Domoticz version:
Location: United States
Contact:

Re: Make blockly Else if to an actual else if

Post by ash77 » Saturday 24 February 2018 2:22

Yeah, I spoke too soon. When m_events is filled from the database for Blockly events, it just remembers a set of condition/action pairs and doesn't remember which Blockly each pair came from.

For example, if I create this Blockly (call it A):

1. condition: temp < 25
action: .....
2. condition: temp > 26
action: .....

then I create a completely different Blockly (call it B):

1. condition: hum > 40
action: .....
2. condition: hum > 20
action: .....

When m_events is loaded, it contains:

1. condition: temp < 25
action: .....
2. condition: temp > 26
action: .....
3. condition: hum > 40
action: .....
4. condition: hum > 20
action: .....

with no way to determine that 1 and 2 came from Blockly A and 3 and 4 came from Blockly B. With the change I suggested, if #1 evaluates to true, it will never evaluate 3 which is incorrect.
It will be necessary to change the code in CEventSystem::LoadEvents() to retain EMID for each row from EventRules.
When a true condition is found (after parseBlocklyActions()), skip all remaining items in m_events with the same EMID as the one that was true.

All that being said, I agree with leonmoonen that this change is going to break some existing Blockly scripts. You can count on it.

User avatar
gizmocuz
Posts: 8721
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: Make blockly Else if to an actual else if

Post by gizmocuz » Saturday 24 February 2018 10:22

@ash77, not sure i understand, but m_events (or the database is easier to check) is correct looking at your actions
You configured 4 actions (no complicated else stuff), and 4 actions are created and will be checked.
No need to know it is from A or B

Unless you meand that 2. condition: temp>26 was a 'else', in this case i can say that never worked and was/is the problem.
It won't break, making the patch will actually solve issues
Quality outlives Quantity!

Xztraz
Posts: 136
Joined: Tuesday 31 January 2017 22:54
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Make blockly Else if to an actual else if

Post by Xztraz » Monday 26 February 2018 0:20

i guess this fix excludes else (only else) ? or is it possible to integrate that too? :)

User avatar
i3laze
Posts: 8
Joined: Thursday 26 July 2018 9:48
Target OS: Windows
Domoticz version:
Contact:

Re: Make blockly Else if to an actual else if

Post by i3laze » Thursday 26 July 2018 10:01

I'm trying to implement If [cond.] Do Else Do..

When I leave 'Else if' :arrow: condition as empty, Else Do-block doesn't fire.
Where can I get a 'True' block? :D

How about changing block's behavior for omitted condition to 'True' or adding simple 'Else' as a ⚙ block option?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests