Blockly examples

Must be cleaned all topics go to the right subforum
User avatar
BartdaMan
Posts: 20
Joined: Sunday 22 May 2016 22:58
Target OS: Raspberry Pi
Domoticz version:
Location: Amersfoort
Contact:

Re: Blockly examples

Postby BartdaMan » Monday 17 October 2016 20:21

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
Domoticz version:
Contact:

Re: Blockly examples

Postby bacinatorz » Thursday 20 October 2016 18:14

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!

mAiden88
Posts: 5
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby mAiden88 » Sunday 23 October 2016 10:45

Here my example..

Image

But it dont works got a error..

Image

:(

Derik
Posts: 1471
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Blockly examples

Postby Derik » Sunday 23 October 2016 12:15

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 620 times

Do i something wrong.?
Or is OTG not integrated in Blockley..?
..
CB 2: 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: 3
Joined: Wednesday 05 October 2016 11:08
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby delfisastre » Monday 07 November 2016 0:27

: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 526 times

Derik
Posts: 1471
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Blockly examples

Postby Derik » Monday 07 November 2016 1:41

looks the actual i not working?
Strange perhaps some that make the blockley can fix this..[ gizmocuz not i believe ]
CB 2: 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: 3
Joined: Wednesday 05 October 2016 11:08
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby delfisastre » Monday 07 November 2016 22:09

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 11:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby ztocken » Monday 07 November 2016 23:06

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 473 times


Anyone have a suggestion? :)

geezerrr
Posts: 117
Joined: Tuesday 02 December 2014 23:16
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Postby geezerrr » Tuesday 08 November 2016 0:06

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: 423
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Postby StanHD » Tuesday 08 November 2016 8:20

Also that's the wrong block for minutes. Try using the number block not a time 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, HA-Bridge with Amazon Echo / Alexa.

bjacobse
Posts: 21
Joined: Tuesday 06 September 2016 9:08
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby bjacobse » Wednesday 09 November 2016 22:30

Ztocken,
This blockly is working with sunset and minutes, use as guide/inspiration
blockly.png
blockly.png (36.12 KiB) Viewed 413 times

bonterra
Posts: 7
Joined: Wednesday 19 October 2016 13:53
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly examples

Postby bonterra » Monday 14 November 2016 12:45

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: 260
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Blockly examples

Postby emme » Monday 14 November 2016 13:21

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
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in a mess!!

four2six
Posts: 48
Joined: Wednesday 24 February 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Location: NRW, Germany
Contact:

Re: Blockly examples

Postby four2six » Monday 14 November 2016 13:29

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: 12
Joined: Wednesday 17 February 2016 23:55
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby sailmich » Monday 14 November 2016 18:06

@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 313 times

four2six
Posts: 48
Joined: Wednesday 24 February 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Location: NRW, Germany
Contact:

Re: Blockly examples

Postby four2six » Tuesday 15 November 2016 10:23

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: 7
Joined: Wednesday 19 October 2016 13:53
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly examples

Postby bonterra » Tuesday 15 November 2016 18:26

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: 12
Joined: Wednesday 17 February 2016 23:55
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby sailmich » Tuesday 15 November 2016 23:13

@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 239 times
Bildschirmfoto vom 2016-11-15 21-50-44.png
Bildschirmfoto vom 2016-11-15 21-50-44.png (13.24 KiB) Viewed 239 times
Bildschirmfoto vom 2016-11-15 21-51-01.png
Bildschirmfoto vom 2016-11-15 21-51-01.png (12.97 KiB) Viewed 239 times

I should more often create virtual switches 8-)

regards

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

Re: Blockly examples

Postby HBrandt » Wednesday 16 November 2016 0:03

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: 12
Joined: Wednesday 17 February 2016 23:55
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blockly examples

Postby sailmich » Wednesday 16 November 2016 7:55

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


Return to “Scripts [cleaning in progress]”

Who is online

Users browsing this forum: lost and 4 guests