Page 1 of 1
Help needed with this blocky
Posted: Monday 26 November 2018 21:55
by astrapowerrr
I can’t get this blocky to work.
My variable sets to 1 after 330 seconds.
But after 330 second with still tapwater on and variable set to 1 my switch douche actief won’t go to on. And tapwater won’t go back to 0.
But when I switch of tapwater with the variable set to 1, the Variable will go back to 0.
The reason for this blocky is to know when I am in the shower.
And this is only when the switch tapwater is longer then 330 seconds active.
Together with some other input.
This 330 sec is needed because my tapwater keeps heated by my cv sometimes and that takes 300 sec.
I hope someone can help me here....
Verzonden vanaf mijn iPhone met Tapatalk
Re: Help needed with this blocky
Posted: Tuesday 27 November 2018 7:07
by Jan Jansen
Remove Set VAR S-Z Tapwater after Set A-F Douche actief = On
Re: Help needed with this blocky
Posted: Tuesday 27 November 2018 7:07
by mrf68
IMHO this script will never reach the second statement, because if the second is true, then also the first is true and it will stop there.
Re: Help needed with this blocky
Posted: Tuesday 27 November 2018 21:18
by astrapowerrr
@jan jansen i removed the var... but still not working?
@mrf68 can you explain.. because i looked at this blocky for ours and i realy dont see what is wrong...
as read my blocky...
when the switch tapwater is on set var to 1 after 330sec.
then when the switch tapwater is on and var is 1(so that will be after 330 seconds) set switch douche actief on and reset var back to 0
and when tapwater is off after 200 sec for example
then tapwater is off and 130 sec later var will be 1 so that means rule 3 tapwater of and var 1 means switch douche actief off and reset var back to 0
as i am typing this i just dont see what is wrong and why??
Re: Help needed with this blocky
Posted: Tuesday 27 November 2018 21:43
by felix63
What @mrf68 means is that the logic of you blocky works other that you expect.
if a then x
elseif a and b then y
elseif not a and b then z
means that if a is true x will be executed and the remainder of the if statement will not be evaluated. The test 'a and b' will be never evaluated. So you could change the statement to
if a and b then x
elseif a then y
elseif not a and b then z
Re: Help needed with this blocky
Posted: Tuesday 27 November 2018 22:42
by mrf68
Just imagine what happens:
Tapwater is on, blockly starts:
“ if tapwater is on then do something “
Okay. Then there is an else/if. That will not be executed, because there is no need for an else. The first statement is
TRUE, so that’s it. You could add a check to the first statement: .... and var tapwater <> 1
Overall people try to put as many things in one blockly and then experience some problems with it. Start with one statement and test it. In this case make 3 different blocklys and check the log for results.
Re: Help needed with this blocky
Posted: Tuesday 27 November 2018 22:56
by astrapowerrr
@mrf68 will try that... thanks..
so i make 3 blockys and see what happens step by step.
edit:
i extracted it to 3 blockys.
the first works, tapwater on sets after 330 seconds the var to 1
2nd blocky i did if var=1 set "douche actief on"
here it gets tricky.
when i use the first blocky and the var gets to 1 nothing happens(douche actief stays off)
but when i manually change the var from 0 to 1 douche actief switches on???

Re: Help needed with this blocky
Posted: Wednesday 28 November 2018 6:56
by mrf68
I don’t use blockly that much anymore, but if I remember correctly the change of the value of a variable will not trigger a blockly. You can set a variable, you can use it to compare it to something, but it will not trigger an action itself. At least, that was in the old days and I am not sure if this behaviour has changed.
Instead of using variables you could try to use dummy switches. If the value of a variable only changes from 0 to 1 or vice versa, then you can use a dummy switch for that (and set it On or Off). Try to replace the variable with a dummy switch and try again.
Re: Help needed with this blocky
Posted: Wednesday 28 November 2018 7:36
by clinicdarman
check to the first statement
Re: Help needed with this blocky
Posted: Wednesday 28 November 2018 16:08
by astrapowerrr
mrf68 wrote:I don’t use blockly that much anymore, but if I remember correctly the change of the value of a variable will not trigger a blockly. You can set a variable, you can use it to compare it to something, but it will not trigger an action itself. At least, that was in the old days and I am not sure if this behaviour has changed.
Instead of using variables you could try to use dummy switches. If the value of a variable only changes from 0 to 1 or vice versa, then you can use a dummy switch for that (and set it On or Off). Try to replace the variable with a dummy switch and try again.
That did it!!
Never knew that a variable could not switch a switch.
Verzonden vanaf mijn iPhone met Tapatalk
Re: Help needed with this blocky
Posted: Wednesday 28 November 2018 18:18
by mrf68
I’m glad it works. Maybe it is not the most elegant or efficient way, but the most important part of automation is that it works.
Glad I could help.
Regards,
Martin