I'm having a problem with one of my blocky events. I suspect I've got a fundamental misunderstanding of the way it works. Maybe someone can help me?
Essentially, I want some logic as follows:
If SwitchA = 1 and SwitchB = 1, set SwitchB to 2.
Else if Switch A = 1 and Switch B =2, set SwitchB to 3.
I have implemented this in Blocky but if I then set Switch A to 1 and Switch B to 1, Switch B changes to 3 whereas I would expect it to be 2.
From the log, I can see that what is happening is that the first part is running (and Switch B is set to 2) and then the event is immediately triggered again and this time the second part is applied and Switch B is set to 3.
Can anyone give me any tips?
Help with Else If logic
Moderator: leecollings
- sisaenkov
- Posts: 50
- Joined: Friday 27 May 2016 7:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8
- Location: Moscow, Russia
- Contact:
Re: Help with Else If logic
This works as expected. All is correct and meets the conditions.
What do you want to do?
What do you want to do?
-
- Posts: 12
- Joined: Tuesday 06 December 2016 20:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Help with Else If logic
Without going into loads of detail, when Switch A is set to 1 for the first time, I want to set Switch B to 2. When Switch A is set to 1 for the second time, I want to set Switch B to 3.
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: Help with Else If logic
you want a toggle button.....
try this:
the first block is a simple IF
the inner block is a IF/else block
(they are different )
try this:
Code: Select all
If SwitchA = 1 then
If SwitchB = 2 then
SwitchB = 0
SwitchC = 3
else
SwitchB = 2
SwitchC = 0
the inner block is a IF/else block
(they are different )
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- sisaenkov
- Posts: 50
- Joined: Friday 27 May 2016 7:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8
- Location: Moscow, Russia
- Contact:
Re: Help with Else If logic
Also you can use a variable.
If SwitchA == 1 and SwitchB == 1 and Var == 0 then
SwitchA = 0
SwitchB = 2
Var = 1
elseif SwitchA == 1 and SwitchB == 2 and Var == 1 then
SwitchA = 0
SwitchB = 3
Var = 1
It's all depends on your detailed conditions.
If SwitchA == 1 and SwitchB == 1 and Var == 0 then
SwitchA = 0
SwitchB = 2
Var = 1
elseif SwitchA == 1 and SwitchB == 2 and Var == 1 then
SwitchA = 0
SwitchB = 3
Var = 1
It's all depends on your detailed conditions.
-
- Posts: 625
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: Help with Else If logic
I think blockly is the problem in this case, try with lua.
-
- Posts: 12
- Joined: Tuesday 06 December 2016 20:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Help with Else If logic
I managed to get it to work with a variable. Thanks for the suggestions.
-
- Posts: 20
- Joined: Thursday 29 December 2016 9:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Help with Else If logic
Domoticz blocky 'else if' handling is broken. Nothing should be run after a condition has been true.
Who is online
Users browsing this forum: No registered users and 0 guests