Page 1 of 1

Turn Light On

Posted: Wednesday 21 June 2017 11:50
by Padster
Hi,

I have a number of 'Light' devices. I can turn the light on and off manually by clicking the 'bulb' icon on the device. However if I am creating a Blockly script and use the 'Logic' 'Set' statement to set the device to 'On' it won't turn the light on. If I create a scene or group with the light device I can turn it on using the scene/group set statement.

Am I supposed to be able to turn a light on using the Logic 'Set' statement? If yes any idea why its not working?

Re: Turn Light On

Posted: Wednesday 21 June 2017 11:55
by StanHD
Should work, here is an example that works:-

Image

Can you show your Blockly?

Re: Turn Light On

Posted: Wednesday 21 June 2017 12:06
by Padster
Hi,

Here is the test Blockly - very simple
lamp.JPG
lamp.JPG (18.52 KiB) Viewed 5036 times
Here are the current states
variables.JPG
variables.JPG (56.48 KiB) Viewed 5036 times
The lamp stays off.

My Domoticz info is;

Version: 3.5877
Build Hash: 15b013c
Compile Date: 2016-11-10 15:44:33

Re: Turn Light On

Posted: Wednesday 21 June 2017 12:55
by tommit01
Hi, please
try to use 'On' tile from blockly category 'Logic' instead of string tile and test it again....

P.S.:
I still don't know why this is still called Blocky ... in so many posts ..it is 'Blockly'

BR
Tommit

Re: Turn Light On

Posted: Wednesday 21 June 2017 13:00
by heggink
Indeed. Unlike lua, switch devices need a state, not a string indicating the state.

Re: Turn Light On

Posted: Wednesday 21 June 2017 13:04
by Padster
Yep - thanks guys that sorted it.

Re: Turn Light On

Posted: Wednesday 21 June 2017 13:12
by Hobbybob
tommit01 wrote:Hi, please
P.S.:
I still don't know why this is still called Blocky ... in so many posts ..it is 'Blockly'
Hahaha, even this forum is called Blocky. I've always thought it was Blocky, never noticed the additional L

Re: Turn Light On

Posted: Wednesday 21 June 2017 13:21
by Padster
Hi Guys,

A couple of follow up questions.

Although the Blockly below works - should I be using the switch states rather than a string?
Capture.JPG
Capture.JPG (62.53 KiB) Viewed 5003 times
Also in StanHD's post in this thread his 'and' condition allows for two lines thus making the test format neater. I can only see an inline 'and' condition. How can I format my Blockly's like StanHD?

Re: Turn Light On

Posted: Wednesday 21 June 2017 13:58
by StanHD
Also in StanHD's post in this thread his 'and' condition allows for two lines thus making the test format neater. I can only see an inline 'and' condition. How can I format my Blockly's like StanHD?
Right Click on the "And" block, then select "External Inputs" ;)

Re: Turn Light On

Posted: Wednesday 21 June 2017 14:02
by Padster
Many thanks - I didn't even know you could right click on the Blockly elements.

Re: Turn Light On

Posted: Wednesday 21 June 2017 14:03
by StanHD
See working Blockly below. No strings :)
Image

Re: Turn Light On

Posted: Wednesday 21 June 2017 14:17
by Padster
See if I've got this right :)

It the LR PIR is on AND (LR Lights Auto=on AND LR Updown Light=off)
AND
Living Room < 100
SET Updown Lights Level= 5%

I need to learn Blockly better than I have.

Would this smoke/heat detection work?
Basically if any of the smoke or heat detectors are ON then Set Smoke_Alarm variable to 'On', turn the Alarm Lights On and send a notification.

Else

If all the Heat and smoke sensors are Off set the variable Smoke_Alarm to 'Off' after 6 mins
smoke.JPG
smoke.JPG (51.88 KiB) Viewed 4969 times

Re: Turn Light On

Posted: Wednesday 21 June 2017 15:48
by StanHD
Yes the interpretation of my Blockly is correct :)

Regarding your Blockly, it looks OK to me, however I always use numbers in user variables, but that's just me. Perhaps you could mock something up with some dummy switches to test?

Re: Turn Light On

Posted: Wednesday 21 June 2017 16:23
by Padster
Thanks again.

My Blockly did work when the 'AND' and 'OR' conditions were all inline. Just not sure is nesting them changed the interpretation. I know the order of evaluation is important.

I'll press the smoke alarm test when I get home.