Blockly examples

Moderator: leecollings

pj-r
Posts: 140
Joined: Wednesday 17 December 2014 17:30
Target OS: Linux
Domoticz version: V3.8650
Location: Jyväskylä, Finland
Contact:

Re: Blockly examples

Post by pj-r »

Minglarn wrote:OKey need some help here...
I Want this blocky to be active ony between time from morgning 06:00 and after midnight 00:30 . How do I make the time comparison?
Would this work?
3.JPG
Domoticz uses minutes form begining of day in time comparisons.
So 06:00 == 6*60+0 == 360 and 00:30 0*60+30 == 30.
So your rule is:
if time >= 360 or time <= 30 do your stuff. It should work.

What kinda functionality you are running in the blocky? Is it event based(state change) or time based(once a minute)? If its event based you could also use dummy switch and its timer to turn it on or off. Then just use that switch state to compare if run blocky or not.
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Blockly examples

Post by Minglarn »

Thanks for the info...
The event is event based.

Dummy switch and LUX lower than 100 and is TIME from 06:30 to 00:30
The Dummy Switch are controlling automatic light on or off...

So, if Dummy Swich is ON and LUX is lower than 100 and the clock is from 06:30 to 00:30 the light should (based on LUX and clock) turn ON and if LUX is over 100 then the light should turn off in timespan: 06:30 to 00:30 ..

I think I figured it out... Have to test it first...
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Blockly examples

Post by Minglarn »

Think i've managed to sole my issue... =)
Please correct me if it's wrong...

So this blocky reacts upon event recived from my LUX meter. But only if "Automatik ...." is enabled. And IF it is it checks time as I only want this to be triggerd between 06:00 from the morning and till 00:30 after midnight.

edit: Something wrong with this script... It Went bananas 06:00 (with on off) for about 30 minutes... Dont really now why... Help...
Attachments
4.JPG
4.JPG (72.86 KiB) Viewed 5398 times
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Blockly examples

Post by Minglarn »

Shame on me. Did forget to check when my motion script deactivates. :)

My motion script was active between 00:00 and 06:30. Changed that to 00:00 to 05:59.
From 06:00 to 23:59 my LUX script takes over the control:)
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
Rena
Posts: 19
Joined: Monday 21 September 2015 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version: V 3.8153
Location: Sweden
Contact:

Re: Blockly examples

Post by Rena »

Hi,

I´m a totally newbie on Domoticz and Blockly. Just want to start with a simple example which isn´t working.
I have set up a dummy-switch which is called "solen", ON when the sun is down and off during the day, based on sunrise. The dummy works fine, status changed when the sun goes down.

Why won´t this simple example work? The lamps won´t light up.
The event is active, anything else I must configure to get events working? I´m running a Rasp Pi.
Blockly test
Blockly test
Blockly.JPG (26.26 KiB) Viewed 5348 times
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Blockly examples

Post by Minglarn »

Hej or Hello....

Why not do this way:
8.JPG
8.JPG (19.8 KiB) Viewed 5348 times
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
Rena
Posts: 19
Joined: Monday 21 September 2015 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version: V 3.8153
Location: Sweden
Contact:

Re: Blockly examples

Post by Rena »

I have read it´s better to have a dummy-swith. But, just too confirm, everything looks fine in my example?
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Blockly examples

Post by Minglarn »

It looks just fine! Should work...

Btw, did you active the BLOCKY?
Attachments
9.JPG
9.JPG (16.73 KiB) Viewed 5349 times
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
Rena
Posts: 19
Joined: Monday 21 September 2015 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version: V 3.8153
Location: Sweden
Contact:

Re: Blockly examples

Post by Rena »

Now it works, I don´t know why.....but it works.

If I want to turn off the lights manual by my phone, the script put them on again. Is there any way to control this?
For example, the light should to turn off at 23:00, but one evening I´m tired and want to turn them off at 22:30.
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Blockly examples

Post by Minglarn »

Make a dummy switch. Name it like "Automatik ljus" and do a check if it "ON" use "SOLEN" otherwise switch of...

Example:

IF SOLEN = ON and AUTOMATIK = ON
SET LAMPA = ON
ELSE IF SOLEN = ON and AUTOMAIK = OFF
SET LAMPA = OFF

By this way the "LAMPA" will turn off is AUTMATIK is off else it will stay ON ...
Try this:
10.JPG
10.JPG (47.46 KiB) Viewed 5344 times
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
Rena
Posts: 19
Joined: Monday 21 September 2015 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version: V 3.8153
Location: Sweden
Contact:

Re: Blockly examples

Post by Rena »

Thanks!
kurniawan77
Posts: 46
Joined: Wednesday 21 January 2015 20:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Blockly examples

Post by kurniawan77 »

okay, i'm trying to do something in blockly which is maybe not possible...

I have a "someone home" status and want to have an "Away" status which will be triggered 30 minutes after "someone home" goes off. With this "Away" status, i trigger a notification to be sent when for example the heater is still on (this is done in an other blockly script).
I now just found out that when i come back home earlier then a half hour... i still get the notification.

Is there some way that i can cancel the timer?
Knipsel.PNG
Knipsel.PNG (21.24 KiB) Viewed 5319 times
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Blockly examples

Post by ThinkPad »

Not with Blockly i'm afraid. The "SET xx AFTER xx seconds" parameter will always be executed, even when the conditions have changed in the meantime.

Convert it to a Lua script, it isn't that hard :) Enough examples available: http://domoticz.com/wiki/Category:Lua
I am not active on this forum anymore.
kurniawan77
Posts: 46
Joined: Wednesday 21 January 2015 20:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Blockly examples

Post by kurniawan77 »

ThinkPad wrote:Not with Blockly i'm afraid. The "SET xx AFTER xx seconds" parameter will always be executed, even when the conditions have changed in the meantime.

Convert it to a Lua script, it isn't that hard :) Enough examples available: http://domoticz.com/wiki/Category:Lua

Haha... i already mentioned it with my colleagues... i have to learn Lua
kurniawan77
Posts: 46
Joined: Wednesday 21 January 2015 20:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Blockly examples

Post by kurniawan77 »

So is this the correct way?

Code: Select all

commandArray = {}
 if (devicechanged['Someone home'] == 'Off' > 1800 and otherdevices['Away'] == 'Off') then
     print('Away timer script: Nobody's home for 30 min. Switching to Away')
     commandArray['Away']='On'
 
 elseif (devicechanged['Someone home'] == 'On' and otherdevices['Away'] == 'On') then
     print('Away timer script: Someonebody's home...')
     commandArray['Away']='Off'
 end
 return commandArray
movingdots
Posts: 1
Joined: Wednesday 30 September 2015 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by movingdots »

Hi,

I'm trying to make a simple blocky script where i can toggle u hue lamp with push on-off button

It seems to work when i use 2 different scripts and only use the off or on script.
But when i try to combine the 2 scripts in one script or activate both the on and off script, it doesn't work.

This is my try with the combined script.

Image

This looks so stupidly simple but i cant get it to work.

When i push the button i would like the lamp to turn on if it isn't already on

when i push the button when the lamp is on i would like the lamp to turn off.

What am i missing?

Thanks a lot !

Linus
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Blockly examples

Post by jake »

Ik heb zoiets ook gehad, volgens mij heeft het met timing te maken. De set commando wordt dan al uitgevoerd voordat de tweede else if wordt bekeken. Die tweede else if schakelt de lamp dan weer uit. Misschien zie je het nog niet eens, maar wel in de log.

Sorry, the Dutch words on the switches made me forget to answer in English. And on a phone I don't like to type the answer twice.
DennisD
Posts: 51
Joined: Friday 18 September 2015 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by DennisD »

Hi,

Sorry noob here, i need some help creating a blocky event. What i'm trying to do is switch on/off a dummy switch when somebody is presence at home in order to turn on my lights when it turns dark outside. I have the presence script installed and it works great (ping ip phones), however when i try to add a dummy switch (iemandthuis) which also was explained here it will only turns off and i have no clue why. What am i doing wrong?
Attachments
blocky.jpg
blocky.jpg (90.1 KiB) Viewed 5118 times
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Blockly examples

Post by pvm »

You should put the 'off' where you've put the and block. Try rebuilding, start with an and block and add the equals block etc.
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
DennisD
Posts: 51
Joined: Friday 18 September 2015 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by DennisD »

Doh, so simple. Thank you works great now :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest