Blockly examples

edje1205
Posts: 24
Joined: Tuesday 20 December 2016 13:09
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Blockly examples

Post by edje1205 » Thursday 26 January 2017 11:35

Hi tozzke

thanx for quick reply !

Now I have this : see att

Still no action. Strange if I physicly connect a light with the dusk sensor (as it is what kaku does main, or I click dusk sensor) that lamp goes on, but no actions in script :roll:

Beside that
In this script will be 'else if' in fact 'do nothing if the light(s) are on yet'. So how can I set blockly in 'do nothing' ?
otherwise (as in your example) , how to say 'do nothing' in lua language ´if connect then end´ or so ?
May be easier in lua ?
Attachments
dusk script2.jpg
dusk script2.jpg (85.15 KiB) Viewed 1667 times

edje1205
Posts: 24
Joined: Tuesday 20 December 2016 13:09
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Blockly examples

Post by edje1205 » Thursday 26 January 2017 16:55

This 'seems' to work ! :) waiting .........
Attachments
dusk script 3.jpg
dusk script 3.jpg (112.63 KiB) Viewed 1666 times

tozzke
Posts: 123
Joined: Friday 02 January 2015 10:22
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke » Thursday 26 January 2017 21:20

Except I don't think 'Stopped' does anything with a light :D

edje1205
Posts: 24
Joined: Tuesday 20 December 2016 13:09
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Blockly examples

Post by edje1205 » Thursday 26 January 2017 21:28

Stopped the script at that point maybe ?

Nautilus
Posts: 677
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Finland
Contact:

Re: Blockly examples

Post by Nautilus » Thursday 26 January 2017 22:39

edje1205 wrote:Stopped the script at that point maybe ?
No, that means it is trying to set the switches to state "Stopped" :)

No need have any separate "stop" commands, it runs when the conditions are met. If you do not need the script to turn the lights off at some point, you don't need the "else if" part at all...
Last edited by Nautilus on Thursday 26 January 2017 23:56, edited 1 time in total.

edje1205
Posts: 24
Joined: Tuesday 20 December 2016 13:09
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Amsterdam Nieuwendam
Contact:

Re: Blockly examples

Post by edje1205 » Thursday 26 January 2017 23:47

:-)

Case closed hm ?

kdalmeijer
Posts: 2
Joined: Friday 27 January 2017 15:26
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by kdalmeijer » Friday 27 January 2017 15:36

Hi guys,

I'm new to the forum and hope you don't mind me asking help for my non-functional blockly. Not entirely true, it does function, but not the way I would expect it to... and what else is new here? :D

Here's the blockly:
2017-01-27 14_22_21-Domoticz.png
2017-01-27 14_22_21-Domoticz.png (37.51 KiB) Viewed 1608 times
It's all about the central ventilation system in the house. I use a Netatmo weather station to read the humidity both in the living room (woonkamer) and in the bathroom (badkamer). Due the the issue I was having with the values from Netatmo, I decided to copy the values to user variables as you can see here:
2017-01-27 14_20_37-Domoticz.png
2017-01-27 14_20_37-Domoticz.png (14.96 KiB) Viewed 1608 times
These values are correct and consistent with what the Netatmo app tells me.

Now the thing is that this blockly considers both situations, humidity above 50 and humidity below 50 to be correct as the logfile shows my debug messages:
2017-01-27 14_23_12-Domoticz.png
2017-01-27 14_23_12-Domoticz.png (8.26 KiB) Viewed 1608 times
I am absolutely puzzled as to why this is happening...
I hope someone is willing and able to help me with this. Thanks in advance!!


BTW: I used the time<>00:00 to get this event to fire every minute so a spend less time testing whether my blockly works :D

User avatar
StanHD
Posts: 541
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Post by StanHD » Friday 27 January 2017 16:11

The problem is probably the "Nested" structure you have used. Blockley does not work with nested "If"s.
Can you try re-structuring by repeating the "time<>00:00" criteria within the "if" and "else if" sections therefore losing the outer "If" block?
Domotica - Intel nuc Celeron, Domoticz - Windows, RFXTRX433E. 1-Wire USB. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub, Broadlink RM2, HA-Bridge with Amazon Echo / Alexa.

kdalmeijer
Posts: 2
Joined: Friday 27 January 2017 15:26
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by kdalmeijer » Friday 27 January 2017 16:47

@StanHD You are my absolute hero! Thanks for pointing that out to me!

This is what I ended up with, and it does exactly what I want. I'll expand from here, adding both speeds of the ventilation and adding CO2 measurements from the Netatmo modules. Happy! :D

Thanks again!
2017-01-27 15_44_09-Domoticz.png
2017-01-27 15_44_09-Domoticz.png (35.49 KiB) Viewed 1595 times

User avatar
StanHD
Posts: 541
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Post by StanHD » Friday 27 January 2017 21:36

Domotica - Intel nuc Celeron, Domoticz - Windows, RFXTRX433E. 1-Wire USB. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub, Broadlink RM2, HA-Bridge with Amazon Echo / Alexa.

tontze
Posts: 242
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by tontze » Sunday 29 January 2017 18:07

Hi ! My second attempt on making blockly :) I cant figure out why this wont work .. Im trying to achieve automatic lights on after sunset.

If i add just motion sensor, it works.
Attachments
sunset.PNG
sunset.PNG (33.35 KiB) Viewed 1541 times
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
ESP82xx

User avatar
StanHD
Posts: 541
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Post by StanHD » Sunday 29 January 2017 18:49

This will only trigger when it is = Sunset (a moment in time) and the motion sensor is on. Try changing to > Sunset and the motion sensor is on. Be aware that > Sunset expires at midnight in Domoticz.
Domotica - Intel nuc Celeron, Domoticz - Windows, RFXTRX433E. 1-Wire USB. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub, Broadlink RM2, HA-Bridge with Amazon Echo / Alexa.

tontze
Posts: 242
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by tontze » Sunday 29 January 2017 18:53

StanHD wrote:This will only trigger when it is = Sunset (a moment in time) and the motion sensor is on. Try changing to > Sunset and the motion sensor is on. Be aware that > Sunset expires at midnight in Domoticz.
Gotta try that, i also tried this: didnt work either :(
Attachments
sunset2.PNG
sunset2.PNG (18.16 KiB) Viewed 1537 times
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
ESP82xx

tontze
Posts: 242
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by tontze » Sunday 29 January 2017 19:02

And changing = to > or < didnt work :/
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
ESP82xx

User avatar
StanHD
Posts: 541
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Post by StanHD » Sunday 29 January 2017 19:08

Ok, you could try making a dummy switch called something like "Is Dark". Set up the switch's timers to on at sunset, off at sunrise. Then use this switch status in your Blockly.
Domotica - Intel nuc Celeron, Domoticz - Windows, RFXTRX433E. 1-Wire USB. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub, Broadlink RM2, HA-Bridge with Amazon Echo / Alexa.

tontze
Posts: 242
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by tontze » Sunday 29 January 2017 19:31

StanHD wrote:Ok, you could try making a dummy switch called something like "Is Dark". Set up the switch's timers to on at sunset, off at sunrise. Then use this switch status in your Blockly.
Thnx ! that worked !
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
ESP82xx

tozzke
Posts: 123
Joined: Friday 02 January 2015 10:22
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke » Monday 30 January 2017 15:58

tontze wrote:
StanHD wrote:This will only trigger when it is = Sunset (a moment in time) and the motion sensor is on. Try changing to > Sunset and the motion sensor is on. Be aware that > Sunset expires at midnight in Domoticz.
Gotta try that, i also tried this: didnt work either :(
Somehow some people manage to mix the blocks in a way it doesn't work :roll:
It isn't that difficult... Mind the brackets

Code: Select all

If [[[Time >= [Sunset]] or [Time <= [Sunrise]]] and [[Motion] = [On]]]
Do [Set [Kitchen lights] = [Off] After [3*] seconds]
* Domoticz/blockly doesn't allow timed events shorter than 3 seconds

tontze
Posts: 242
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by tontze » Monday 30 January 2017 16:25

tozzke wrote:
tontze wrote:
StanHD wrote:This will only trigger when it is = Sunset (a moment in time) and the motion sensor is on. Try changing to > Sunset and the motion sensor is on. Be aware that > Sunset expires at midnight in Domoticz.
Gotta try that, i also tried this: didnt work either :(
Somehow some people manage to mix the blocks in a way it doesn't work :roll:
It isn't that difficult... Mind the brackets

Code: Select all

If [[[Time >= [Sunset]] or [Time <= [Sunrise]]] and [[Motion] = [On]]]
Do [Set [Kitchen lights] = [Off] After [3*] seconds]
* Domoticz/blockly doesn't allow timed events shorter than 3 seconds
Thats good to know :) Was that the problem with my blockly ? I still dont see anything wrong with it (besides that 1sec that i know now).

Oh, just now i remembered that i used 1sec delay with motion to start lights (without sunset) and it worked ?
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
ESP82xx

tontze
Posts: 242
Joined: Thursday 12 January 2017 16:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Post by tontze » Monday 30 January 2017 16:39

Oh, now i see it :) Open brackets left behind right ?
-----------------------------------------
Rpi 3 / Razberry 2
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
ESP82xx

tozzke
Posts: 123
Joined: Friday 02 January 2015 10:22
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke » Monday 30 January 2017 17:29

Sunset/rise have to be linked into the Time-blockly
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests