Page 11 of 36
Re: Blockly examples
Posted: Wednesday 16 September 2015 9:15
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.
Re: Blockly examples
Posted: Wednesday 16 September 2015 10:20
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...
Re: Blockly examples
Posted: Wednesday 16 September 2015 17:42
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...
Re: Blockly examples
Posted: Friday 18 September 2015 19:51
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:)
Re: Blockly examples
Posted: Monday 21 September 2015 20:23
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.JPG (26.26 KiB) Viewed 5364 times
Re: Blockly examples
Posted: Monday 21 September 2015 20:32
by Minglarn
Hej or Hello....
Why not do this way:
- 8.JPG (19.8 KiB) Viewed 5364 times
Re: Blockly examples
Posted: Monday 21 September 2015 20:41
by Rena
I have read it´s better to have a dummy-swith. But, just too confirm, everything looks fine in my example?
Re: Blockly examples
Posted: Monday 21 September 2015 20:43
by Minglarn
It looks just fine! Should work...
Btw, did you active the BLOCKY?
Re: Blockly examples
Posted: Monday 21 September 2015 20:47
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.
Re: Blockly examples
Posted: Monday 21 September 2015 20:56
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 (47.46 KiB) Viewed 5360 times
Re: Blockly examples
Posted: Tuesday 22 September 2015 7:43
by Rena
Thanks!
Re: Blockly examples
Posted: Friday 25 September 2015 11:47
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 (21.24 KiB) Viewed 5335 times
Re: Blockly examples
Posted: Friday 25 September 2015 11:53
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
Re: Blockly examples
Posted: Friday 25 September 2015 12:00
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
Re: Blockly examples
Posted: Saturday 26 September 2015 16:30
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
Re: Blockly examples
Posted: Wednesday 30 September 2015 23:04
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.
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
Re: Blockly examples
Posted: Thursday 01 October 2015 0:22
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.
Re: Blockly examples
Posted: Monday 05 October 2015 22:26
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?
Re: Blockly examples
Posted: Monday 05 October 2015 23:58
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.
Re: Blockly examples
Posted: Tuesday 06 October 2015 17:10
by DennisD
Doh, so simple. Thank you works great now