Blockly examples

Moderator: leecollings

shamie
Posts: 8
Joined: Wednesday 20 June 2018 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by shamie »

tried to creat a blockly but i cannot make it with some dependancies.

if i turn on my computer i want that my desklight to be turned on, and if i quit computing i want it to turn off, for that i have the following:

Image

and for off:

Image

pretty much straight forward, no big deal and works like a charm.
only i want to extend it that if it is past sunset the light wil go on, otherwise not.
i tried several options like the one below but it doesnt work at all.

Image

what may go wrong and can someone help me out here?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by waaren »

shamie wrote: Monday 01 October 2018 20:38 tried to creat a blockly but i cannot make it with some dependancies.

if i turn on my computer i want that my desklight to be turned on, and if i quit computing i want it to turn off
I want to extend it that if it is past sunset the light wil go on, otherwise not.
what may go wrong and can someone help me out here?
The Blockly with the check if it is past sunset is not correct.
It will test if the state of the PC is ("On" and time > sunset) This will lead to an unknown comparevariable logic_operation

A correct Blockly is:
Knipsel.PNG
Knipsel.PNG (17.6 KiB) Viewed 4387 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
shamie
Posts: 8
Joined: Wednesday 20 June 2018 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by shamie »

waaren wrote: Monday 01 October 2018 21:09
shamie wrote: Monday 01 October 2018 20:38 tried to creat a blockly but i cannot make it with some dependancies.

if i turn on my computer i want that my desklight to be turned on, and if i quit computing i want it to turn off
I want to extend it that if it is past sunset the light wil go on, otherwise not.
what may go wrong and can someone help me out here?
The Blockly with the check if it is past sunset is not correct.
It will test if the state of the PC is ("On" and time > sunset) This will lead to an unknown comparevariable logic_operation

A correct Blockly is:
Knipsel.PNG
Thanks for the clarification, it make sense, i must keep in mind that a state is not transfered to another block.

thank you for the help, it works now
Himmy
Posts: 4
Joined: Wednesday 24 January 2018 22:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Events: Blockly examples

Post by Himmy »

bistoury wrote: Monday 15 July 2013 22:40 My first heating scenario.
I am afraid I will need to dig into LUA...

blocky_heating_19.jpg
Hey there
I saw a post from you from 2013 where you showed a blockly if else-action.
What i found surprising is that your AND components were vertical in stead of horizontal
So it was:
ANS variabel1 in stead of what i always get variabel1 AND variabel2
variabel2
Your vizualisation makes less wide blockly scripts which are better readable. How did you fixed this?

WHI
tozzke
Posts: 135
Joined: Friday 02 January 2015 9:22
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Events: Blockly examples

Post by tozzke »

Himmy wrote: Tuesday 30 October 2018 9:14
bistoury wrote: Monday 15 July 2013 22:40 My first heating scenario.
I am afraid I will need to dig into LUA...

blocky_heating_19.jpg
Hey there
I saw a post from you from 2013 where you showed a blockly if else-action.
What i found surprising is that your AND components were vertical in stead of horizontal
So it was:
ANS variabel1 in stead of what i always get variabel1 AND variabel2
variabel2
Your vizualisation makes less wide blockly scripts which are better readable. How did you fixed this?

WHI
Right click on the block you want and click 'external inputs'
uschuga
Posts: 19
Joined: Friday 26 October 2018 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Germany
Contact:

Re: Blockly examples

Post by uschuga »

This is my first step learning more about blockly and I started with this simple example:
Domo01.jpg
Domo01.jpg (11.35 KiB) Viewed 3938 times
R02 turned on correctly when P02 was switched on, but R02 did not switched of after 1 minute. Exchanging both switches does not work ether. What went wrong?
Used Z-Wave devices: EUR_SPIRITZ, FGBS001, FGR223, FGS223, FGBS222, ZMNHYD1 Smart Plug 16A, ZWA009 AërQ Sensor, NAS-WR01Z Power plug 12A, ZME_WALLC-S, FGD212, ST812 Flood Detector, PAN04-1 Double Relay Switch, ZMNHND1 Flush 1D relay, ZME_UZB1 USB Stick
tozzke
Posts: 135
Joined: Friday 02 January 2015 9:22
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke »

uschuga wrote: Tuesday 30 October 2018 21:27 This is my first step learning more about blockly and I started with this simple example:

Domo01.jpg

R02 turned on correctly when P02 was switched on, but R02 did not switched of after 1 minute. Exchanging both switches does not work ether. What went wrong?
First of all I'd use the single digit blockly and not the time blockly for telling it to turn on for 1 minute.
Secondly you'd like it to turn on for 1 minute and off afterwards... However 'On for x minutes' does just that... turns something on for x minutes, not off afterwards but teels it to go "back" to its previous state. If it was off, it'll turn off but when it was already on, it'll turn "back" on again (check the log of the switch)

I'd use (and make sure the type of event is set to 'Device' to prevent retriggering):

Code: Select all

If [.P02_Switch] = [On] 
Do [Set [.R02_1_Licht_Terasse] = [On]]
Do [Set [.R02_1_Licht_Terasse] = [Off] after [60] seconds]
uschuga
Posts: 19
Joined: Friday 26 October 2018 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Germany
Contact:

Re: Blockly examples

Post by uschuga »

Perfect, now it works well. Thank you!

However, there was another syntax challenge responsible for some other strange observations on my side:
10 seconds = [10:00], not [00:10].

What is the background to set the type of event to "Device"? In which cases the other types are appropriate?
Used Z-Wave devices: EUR_SPIRITZ, FGBS001, FGR223, FGS223, FGBS222, ZMNHYD1 Smart Plug 16A, ZWA009 AërQ Sensor, NAS-WR01Z Power plug 12A, ZME_WALLC-S, FGD212, ST812 Flood Detector, PAN04-1 Double Relay Switch, ZMNHND1 Flush 1D relay, ZME_UZB1 USB Stick
tozzke
Posts: 135
Joined: Friday 02 January 2015 9:22
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke »

Regarding the 10 seconds... that's why I said you'd better not use the time ([..:..])block for that to prevent unforseen reactions.
When you set your event to 'Device', it'll only trigger on a device change on devices in the if-statement(s), 'Time' will trigger every minute, link
AYAMY
Posts: 21
Joined: Sunday 27 May 2018 11:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by AYAMY »

there is a way with blocky to find the lowest and highest temperature in a day ?
thanks
gtjgtj
Posts: 8
Joined: Sunday 02 December 2018 11:36
Target OS: NAS (Synology & others)
Domoticz version: 3.1 OMV
Contact:

Re: Blockly examples

Post by gtjgtj »

Hello everybody.

I'm new to Domoticz and trying to create my first blocky events.

I have connected a ZWave PIR sensor to a porch light which is triggered no problem when motion is detected.

Ideally, I wanted the light to switch on when motion is detected only between sunset and sunrise.
Therefore, I created:
Image

but that wouldn't work.

Should I try something like this?
Image

Any help will be greatly appreciated.
tozzke
Posts: 135
Joined: Friday 02 January 2015 9:22
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke »

gtjgtj wrote: Sunday 02 December 2018 12:05 Hello everybody.

I'm new to Domoticz and trying to create my first blocky events.

I have connected a ZWave PIR sensor to a porch light which is triggered no problem when motion is detected.

Ideally, I wanted the light to switch on when motion is detected only between sunset and sunrise.
Therefore, I created:
Image

but that wouldn't work.

Should I try something like this?
Image

Any help will be greatly appreciated.
The first blockly is the correct way to do it but you'll have to keep in mind that Domoticz time based events only work on the same day (NOT passing midnight). This means that on the same day it can't be later than sunset and simultaniously earlier than sunrise. That condition will always be false.

With this in mind, you'll have to change it to:
Image

I added the 'and [Front Door Light] = [Off]' to prevent retriggering and '[Set [Front Door Light] = [Off] after [60] seconds]' to turn the light off again
gtjgtj
Posts: 8
Joined: Sunday 02 December 2018 11:36
Target OS: NAS (Synology & others)
Domoticz version: 3.1 OMV
Contact:

Re: Blockly examples

Post by gtjgtj »

tozzke wrote: Monday 03 December 2018 12:09
gtjgtj wrote: Sunday 02 December 2018 12:05 Hello everybody.

I'm new to Domoticz and trying to create my first blocky events.

I have connected a ZWave PIR sensor to a porch light which is triggered no problem when motion is detected.

Ideally, I wanted the light to switch on when motion is detected only between sunset and sunrise.
Therefore, I created:
Image

but that wouldn't work.

Should I try something like this?
Image

Any help will be greatly appreciated.
The first blockly is the correct way to do it but you'll have to keep in mind that Domoticz time based events only work on the same day (NOT passing midnight). This means that on the same day it can't be later than sunset and simultaniously earlier than sunrise. That condition will always be false.

With this in mind, you'll have to change it to:
Image

I added the 'and [Front Door Light] = [Off]' to prevent retriggering and '[Set [Front Door Light] = [Off] after [60] seconds]' to turn the light off again

Thank you so much for the detailed explanation!
I'm sure now that I understood the logic it works.
However, I set it exactly as you suggested and the light turns on and off periodically on an endless loop!

What am I possibly doing wrong?
gtjgtj
Posts: 8
Joined: Sunday 02 December 2018 11:36
Target OS: NAS (Synology & others)
Domoticz version: 3.1 OMV
Contact:

Re: Blockly examples

Post by gtjgtj »

Dear tozzke
I think I got it at last. It seems there was a syntax error in my blockly script.

What I understand is that you have to create the time blocklys first then the ''burglar'' one and then compile them into one line. I was adding blockly by blocky- one by one and that didn't seem to work.

Does that yellow marking when you select the whole blockly show if the complete chain is in effect?
If that's the case, then now when I mark the ''if blockly'' at the beginning of the line it includes all parameters.

The only parameter I have not got to add yet is the one you suggested to prevent retriggering as it keeps failing to include it in the line. However, I think I'll work something out in the end!

Thank you so much. Your response was a ton helpful and to the point!
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

Re: Blockly examples

Post by jimbo213Mo »

Hello
Why is this [my first blockly] not working?
BlocklyTimerFail.jpg
BlocklyTimerFail.jpg (56.56 KiB) Viewed 3312 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by waaren »

jimbo213Mo wrote: Monday 10 December 2018 18:41 Hello
Why is this [my first blockly] not working?
I am no blockly expert but the blocky below works.
btr.png
btr.png (22.17 KiB) Viewed 3303 times

Differences with yours:
Only one If Do block
Time is = hh:mm not >=
Time is entered as hh:mm not hhmm
Scene is set to "On" not "Active"
I am on a recent Beta and cannot choose between Device or Time based blockly but if you can choose, I would go for a time based event.
"your mileage may vary" but this can be a start. Try from here and adjust to see if the blockly keeps working after your changes.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sterremos
Posts: 3
Joined: Tuesday 16 October 2018 15:09
Target OS: -
Domoticz version:
Contact:

Re: Blockly examples

Post by sterremos »

Hi, i have a mi cube and connected to domoticz, i have make a program to change the light to 4 different colours if i turn the cube. make four scene with the colours ,red, green, white and yellow.
After the last turn (yellow) the program has to go on the first scene again (red)
Now its stucks at the last one, can someone give me the clue how the make the loop?


Image

RJ
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Blockly examples

Post by RobbieT »

I'm trying to create a simple blockly that plays a "doorbell" sound when my front door is open:

Image

This is what I currently have, but nothing happens, what am I doing wrong?
tozzke
Posts: 135
Joined: Friday 02 January 2015 9:22
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke »

RobbieT wrote: Thursday 13 December 2018 14:44 I'm trying to create a simple blockly that plays a "doorbell" sound when my front door is open:

Image

This is what I currently have, but nothing happens, what am I doing wrong?
And that's strange because...?
presuming that's the right command for the Xiaomi gateway to make a sound, you're telling it to play at volume ?10%? after 5 minutes but turn it off again after only 5 seconds. It'll never go to that 10% because you're telling it to go off before it even turns to 10%
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Blockly examples

Post by RobbieT »

tozzke wrote: Thursday 13 December 2018 18:47
RobbieT wrote: Thursday 13 December 2018 14:44 I'm trying to create a simple blockly that plays a "doorbell" sound when my front door is open:

Image

This is what I currently have, but nothing happens, what am I doing wrong?
And that's strange because...?
presuming that's the right command for the Xiaomi gateway to make a sound, you're telling it to play at volume ?10%? after 5 minutes but turn it off again after only 5 seconds. It'll never go to that 10% because you're telling it to go off before it even turns to 10%
According to the Xiaomi gateway Wiki (https://wiki.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)) the "level" is for selecting the sound that has to be played. I will set the time to off a bit longer, see what happens.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest