Blockly examples

Moderator: leecollings

User avatar
BartdaMan
Posts: 20
Joined: Sunday 22 May 2016 22:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Amersfoort
Contact:

Re: Blockly examples

Post by BartdaMan »

Bacinatorz,

You can solve this by adding a variable that changes state when the script runs. This way the script only triggers your Ledstrip once.
Here's an example:
https://postimg.org/image/k0dead18r/
bacinatorz
Posts: 2
Joined: Saturday 08 October 2016 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by bacinatorz »

BartdaMan wrote:Bacinatorz,

You can solve this by adding a variable that changes state when the script runs. This way the script only triggers your Ledstrip once.
Here's an example:
https://postimg.org/image/k0dead18r/
Thnx for your clear screenshot, I have done this and now it works!
User avatar
mAiden88
Posts: 56
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Blockly examples

Post by mAiden88 »

Here my example..

Image

But it dont works got a error..

Image

:(
Anyone can build a fast processor. The trick is to build a fast system.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Blockly examples

Post by Derik »

Dear All..
Is there someone that the OTG integrated in Blockley..
I do have a simple test, that is not working..:
ScreenShot074.jpg
ScreenShot074.jpg (67.36 KiB) Viewed 3092 times
Do i something wrong.?
Or is OTG not integrated in Blockley..?
..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
delfisastre
Posts: 18
Joined: Wednesday 05 October 2016 11:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Catalonia, Barcelona
Contact:

Re: Blockly examples

Post by delfisastre »

:oops: I need your help!

I don't know why is not working.
I have a motion sensor in the room, and I want to swicht off the light if the sensor detects no mottion. But the problem is, If I'm wathcing the TV, sometimes, the lights turn off, because the sensor don't detects motion. And put in a blockly. If detects no motion, but the TV is ON. Don't turn off the lights. But! the TV only is OFF is it's completly stops. (no with stantd by) and I put in the blockly if the electrical consumption to the TV is less than 20w ant no detects motion. Turn off the lights... But is not working. :-(

Presencia Menjador = Motion Sensor
Tv = TV
Consum Actual TV = actual electrical consumption TV
Mnejador1 = Light 1
Menjador 2= Light 2
blockly.jpeg
blockly.jpeg (53.21 KiB) Viewed 2998 times
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Blockly examples

Post by Derik »

looks the actual i not working?
Strange perhaps some that make the blockley can fix this..[ gizmocuz not i believe ]
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
delfisastre
Posts: 18
Joined: Wednesday 05 October 2016 11:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Catalonia, Barcelona
Contact:

Re: Blockly examples

Post by delfisastre »

I don't know why.... but now it's working!!! maybe is the cache of the browser... I don't know. But works perfectly. Thanks for your help!
ztocken
Posts: 3
Joined: Tuesday 19 January 2016 10:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by ztocken »

I could use some help with my blockly event.
my devices:
rörelsesensor framsidan = motion sensor outside front of house
Entre = porch lamp
hallen = lamp hallway inside of house.

what i want to do:
if its dark outside i want the porch lamp (Entre) and the hallway lamp (hallen) to turn on for 5 minutes if there is movement outside.
But only if the porch lamp is not already on.

what happends is i get this error:
2016-11-07 21:51:29.319 Error: EventSystem: Lua script error (Blockly), Name: auto lampa framsida_1 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
blockly.PNG
blockly.PNG (17.89 KiB) Viewed 2945 times
Anyone have a suggestion? :)
geezerrr
Posts: 79
Joined: Tuesday 02 December 2014 22:16
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by geezerrr »

ztocken wrote:I could use some help with my blockly event.
my devices:
rörelsesensor framsidan = motion sensor outside front of house
Entre = porch lamp
hallen = lamp hallway inside of house.

what i want to do:
if its dark outside i want the porch lamp (Entre) and the hallway lamp (hallen) to turn on for 5 minutes if there is movement outside.
But only if the porch lamp is not already on.

what happends is i get this error:
2016-11-07 21:51:29.319 Error: EventSystem: Lua script error (Blockly), Name: auto lampa framsida_1 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
blockly.PNG
Anyone have a suggestion? :)
[Sunset = on] isn't a correct statement.
Maybe you can change it in [time >= sunset]
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Post by StanHD »

Also that's the wrong block for minutes. Try using the number block not a time block.
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
bjacobse
Posts: 85
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Sorø, DK
Contact:

Re: Blockly examples

Post by bjacobse »

Ztocken,
This blockly is working with sunset and minutes, use as guide/inspiration
blockly.png
blockly.png (36.12 KiB) Viewed 2885 times
bonterra
Posts: 6
Joined: Wednesday 19 October 2016 13:53
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly examples

Post by bonterra »

I hope someone can help me. I've got a door sensor and a Qubino relay module installed to control a lamp inside my front door. The same light is also connected to a traditional switch for manual control. Door switch is "ON" when the door is open and "OFF" when the door is closed.

I would like to have two separate events, entry and exit. If the lamp is off and the door opens, turn it on for five minutes (entry). If the lamp is on and the door opens, turn it off after two minutes (exit). Both events are very simple but I just can't get them to work together.
I guess I need a dummy switch to separate these two events somehow?
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Blockly examples

Post by emme »

a LUA Device Script could help, but you have to use a variable:

Variable named: DOOROPERATION - string(1)
1 = ENTRY
2 = EXIT
0 = INOP

Code: Select all

commandArray {}
    if devicechanged['DoorSwitchName'] or devicechanged['extLampName'] then
        if otherdevices['extLampName'] == 'Off' and otherdevices['DoorSwitchName'] == 'Off' and uservariables['DOOROPERATION'] = '0' then      -- ENTRY
            commandarray['variable:DOOROPERATION'] = '1'
            commandArray['extLampName'] = 'On FOR 5'
        elseif otherdevices['extLampName'] == 'On' and otherdevices['DoorSwitchName'] == 'Off' and uservariables['DOOROPERATION'] = '0' then      -- EXIT
            commandarray['variable:DOOROPERATION'] = '2'
            commandArray['extLampName'] = 'Off AFTER 2'
        end
         commandarray['variable:DOOROPERATION'] = '0 AFTER 2'
    end
return commandArray
this should works...
Be aware that the uservariable determinates IF an operation is on going on the door... this means that for 2 minutes no action will be taken
There is not a real reason to set the variable to 1 or 2... since it tests only if it is 0 to run (but.. maybe just for debug information)
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
four2six
Posts: 53
Joined: Wednesday 24 February 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NRW, Germany
Contact:

Re: Blockly examples

Post by four2six »

I'd try virtual switches, one called 'entry', one 'exit'.
which leads to:
if 'entry' = 'off' and exit 'off' and 'door' = 'on' and 'lamp' = 'on'
set 'exit' = 'on' for 2 minutes
if 'entry' = 'off' and exit 'off' and 'door' = 'on' and 'lamp' = 'off'
set 'entry' = 'on' for 5 minutes
if 'entry' = 'on' or 'exit = 'on'
set 'lamp' = 'on'
if 'entry' = 'off' and 'exit = 'off'
set 'lamp' = 'off'
sailmich
Posts: 232
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: Blockly examples

Post by sailmich »

@bonterra I tried with success what you want to do. See attachment.

Problem with that is if you changed your mind, for example you have forgotten something inside and you are open the door inside the 120 seconds, you will start the 5 minutes. At least in my opinion you need a PIR sensor inside your room to make the system running perfect.

regards
Attachments
Bildschirmfoto vom 2016-11-14 16-19-41.png
Bildschirmfoto vom 2016-11-14 16-19-41.png (23.4 KiB) Viewed 2785 times
four2six
Posts: 53
Joined: Wednesday 24 February 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NRW, Germany
Contact:

Re: Blockly examples

Post by four2six »

sailmich wrote:Problem with that is if you changed your mind, for example you have forgotten something inside and you are open the door inside the 120 seconds, you will start the 5 minutes.
not with my solution ;-)
bonterra
Posts: 6
Joined: Wednesday 19 October 2016 13:53
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly examples

Post by bonterra »

four2six wrote:I'd try virtual switches, one called 'entry', one 'exit'.
which leads to:
if 'entry' = 'off' and exit 'off' and 'door' = 'on' and 'lamp' = 'on'
set 'exit' = 'on' for 2 minutes
if 'entry' = 'off' and exit 'off' and 'door' = 'on' and 'lamp' = 'off'
set 'entry' = 'on' for 5 minutes
if 'entry' = 'on' or 'exit = 'on'
set 'lamp' = 'on'
if 'entry' = 'off' and 'exit = 'off'
set 'lamp' = 'off'
Thanks, I might go for something like this.
sailmich wrote:@bonterra I tried with success what you want to do. See attachment.

Problem with that is if you changed your mind, for example you have forgotten something inside and you are open the door inside the 120 seconds, you will start the 5 minutes. At least in my opinion you need a PIR sensor inside your room to make the system running perfect.

regards
A PIR would be ideal, then it wouldn't matter if the door was opened twice during the active minutes. I'll have a look and see what I can find.

Thanks for your help, both of you!


Now I just have to figure out why I can't control the second channel of the Qubino (porch light) from the wall switch, it's wired just like the first channel (indoor light)...
sailmich
Posts: 232
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: Blockly examples

Post by sailmich »

@four2six, virtual switches are fantastic. I tried as you wrote in one block but it doesn't work. With three it works. :D
EntryExit.png
EntryExit.png (27.87 KiB) Viewed 2711 times
Bildschirmfoto vom 2016-11-15 21-50-44.png
Bildschirmfoto vom 2016-11-15 21-50-44.png (13.24 KiB) Viewed 2711 times
Bildschirmfoto vom 2016-11-15 21-51-01.png
Bildschirmfoto vom 2016-11-15 21-51-01.png (12.97 KiB) Viewed 2711 times
I should more often create virtual switches 8-)

regards
HBrandt
Posts: 8
Joined: Tuesday 15 November 2016 22:54
Target OS: -
Domoticz version:
Contact:

Re: Blockly examples

Post by HBrandt »

Could these virtual switches not be converted to variables? I find it confusing with all these virtual switches and if they are only used to hold on/off state it seems to be overkill.

Mvh Henrik
sailmich
Posts: 232
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: Blockly examples

Post by sailmich »

@HBrandt , could you please convert my blockly into one with variables. So I could see how it looks.
Thx
Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest