Hello all,
i have made a blocky script to automatically turn off my audio-rack when there is nothing playing with a delay of 1 hour, if you play music within the hour it will "reset" and nothing turns off. but now comes the problem.
I want to automatically turn on my audio-rack when some source of audio is being played.
i have made this but it is not working, i there somebody who can help me??
the part in the red line is the "auto on part".
switch "timer" is a switch with a off delay of 1 hour.
Automated on/off with block script help!
Moderators: leecollings, remb0
-
- Posts: 12
- Joined: Friday 25 November 2016 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Automated on/off with block script help!
- Attachments
-
- blocky script
- Schermafbeelding 2017-02-04 om 19.23.12.png (100.85 KiB) Viewed 759 times
-
- Posts: 3
- Joined: Saturday 11 February 2017 10:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5877
- Location: ::1
- Contact:
Re: Automated on/off with block script help!
Hello,
It seems to me that the last two blocks are never executed. I don't use Blocky, but as a general rule in programming, an if-elseif-elseif statement ensures that **at most** one of the conditions is executed, the first that matches.
In your case, the condition you highlighted would never even get checked, since the if(audio in == open) statement before was true and has been executed.
I would recommend to add a second level of if-else :
I hope this will help you.
It seems to me that the last two blocks are never executed. I don't use Blocky, but as a general rule in programming, an if-elseif-elseif statement ensures that **at most** one of the conditions is executed, the first that matches.
In your case, the condition you highlighted would never even get checked, since the if(audio in == open) statement before was true and has been executed.
I would recommend to add a second level of if-else :
Code: Select all
if (audio in == open)
if (audion-on == on and timer-var = not_triggered)
block 4
else
block 1
end
else
if (audio in == closed and timer == off and timer-var == truggered)
block 3
else
block 2
end
end
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: Automated on/off with block script help!
It seems blockly (at least in Domoticz) is not something that follows all general programming rulesSpottyq wrote:Hello,
It seems to me that the last two blocks are never executed. I don't use Blocky, but as a general rule in programming, an if-elseif-elseif statement ensures that **at most** one of the conditions is executed, the first that matches.
In your case, the condition you highlighted would never even get checked, since the if(audio in == open) statement before was true and has been executed.
I would recommend to add a second level of if-else :
I hope this will help you.Code: Select all
if (audio in == open) if (audion-on == on and timer-var = not_triggered) block 4 else block 1 end else if (audio in == closed and timer == off and timer-var == truggered) block 3 else block 2 end end

For OP's question, I'd maybe try with moving the non-working part to top. And also perhaps think some additional condition for "if 'audio in' = open" so that each if would only match one situation. The best option, though, would be to look into Lua...

Who is online
Users browsing this forum: No registered users and 1 guest