Page 8 of 36
Re: Blockly examples
Posted: Monday 27 April 2015 20:24
by ThinkPad
I am not going to remake your event, that way you don't learn anything from it.
Some hints:
- You need to check every device/switch separately, see also below
- You are not using the 'AND' in the correct way. Use it like this: [lamp1 = On] AND [lamp2 = On].... Not like: lamp1 AND lamp2 = On... won't work
- You are now checking for the EXACT moment of sunset/sunrise. So one minute before/after sunset/sunrise the condition isn't valid anymore
Check the previous pages of this topic for inspiration/guidelines
Re: Blockly examples
Posted: Monday 27 April 2015 21:21
by thecosmicgate
ThinkPad wrote:I am not going to remake your event, that way you don't learn anything from it.
Some hints:
- You need to check every device/switch separately, see also below
- You are not using the 'AND' in the correct way. Use it like this: [lamp1 = On] AND [lamp2 = On].... Not like: lamp1 AND lamp2 = On... won't work
- You are now checking for the EXACT moment of sunset/sunrise. So one minute before/after sunset/sunrise the condition isn't valid anymore
Check the previous pages of this topic for inspiration/guidelines
more like this :
I'am busy with the : zon op (licht), zon onder (donker) ( Sunrise : light , Sunset Dark) blocky , first i'am reading a lot about the possibilities .
should i use Json script (as found on tweakers.net), or just use al blocky example
But how is it possible to create this blocky to learn : when whe arrive at home the light levels up ( %) ?
Re: Blockly examples
Posted: Monday 27 April 2015 23:16
by floris74
leby wrote:Think you need a little bit of lua.. I use a lua script to know how long time have passed since my motion sensor was breached, guess you can exchange the motion sensor with a dummy switch that is turned on when you have >3500 lux.
1) Create o dummy switch
2) Create one user variable named "Dummy switch time" give it a start value of say '1'
3) Make a blockly event that turns on the dummy switch when the sensor is >3500 lux and off if sensor is <3400
4) Add the script below to the script folder
5) now you can build your event and trigger on the value of the variable "Dummy switch time" (for example if its more than 120 or what ever)
Code: Select all
commandArray = {}
t1 = os.time()
t2 = uservariables['Dummy switch time']
r0 = t1-t2
commandArray['Variable:Timewithmorethan3500'] = tostring(r0)
print('Timewithmorethan3500 ' .. r0)
return commandArray
Think this i principle should work with your scenario..
Thanks. i hope i can use this the next days..
Floris
Re: Blockly examples
Posted: Tuesday 28 April 2015 10:46
by thecosmicgate
Could anybody help me , i'am getting this error ( after update to Beta 2385)
Code: Select all
2015-04-28 10:46:00.337 Hardware Monitor: Fetching data (System sensors)
2015-04-28 10:46:00.341 Error: Lua script error (Blockly), Name: Lamp_1 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
2015-04-28 10:46:00.341 Error: Lua script error (Blockly), Name: Lamp_2 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
Re: Blockly examples
Posted: Tuesday 28 April 2015 11:22
by thecosmicgate
thecosmicgate wrote:Could anybody help me , i'am getting this error ( after update to Beta 2385)
Code: Select all
2015-04-28 10:46:00.337 Hardware Monitor: Fetching data (System sensors)
2015-04-28 10:46:00.341 Error: Lua script error (Blockly), Name: Lamp_1 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
2015-04-28 10:46:00.341 Error: Lua script error (Blockly), Name: Lamp_2 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
Solved after delete the event. First i couldn't remove this event (i thought) but it looks like there were serveral "lamp" events , i had to push "delete event" 4 times and everything seems to be ok for now.
Still looking for the self learning event as discribed
Re: Blockly examples
Posted: Wednesday 29 April 2015 14:22
by thecosmicgate
ThinkPad wrote:Event to control virtual switch 'IsDark'
You can use this event to control a virtual switch, called 'IsDark'. You can then use the 'IsDark' in your other events to check if it is dark outside.
You may think, why not use a simple timer to turn this virtual switch on/off?
The timer will only switch at the configured moment. But if that moment is missed because the Pi had a power failure for example, your lights will never turn on after the Pi has booted again, because Domoticz won't check if the switch has turned on if the configured switch time has passed.
The event is different in this, because it will ALWAYS check the conditions and thus works always. If you boot your Pi in the middle of the night (after it has been off for the whole day) and the virtual switch is still in the 'day' setting, the event will turn it to the correct setting (=IsDark is on).
P.S. The 'OR' in the 'ELSE IF' line is correct. Domoticz validates till 23:59, at 0:00 a new day starts. Therefore by using 'AND' the condition will never become true.
I complete "copied" the blockly :
with virtual switch:
But the switch doesn't flip from off to on , if i want to press the switch manually using the web interface it doesn't work or change status .
What's wrong ?
Re: Blockly examples
Posted: Wednesday 29 April 2015 14:57
by StanHD
Hi, does it change state if you temporarily "Reverse" the logic for testing? (Off to On / On to Off etc)
Re: Blockly examples
Posted: Wednesday 29 April 2015 19:37
by thecosmicgate
StanHD wrote:Hi, does it change state if you temporarily "Reverse" the logic for testing? (Off to On / On to Off etc)
Done :
The switch itself doesn't flip
i googled around and found this
witch seems to work okay (except the variable ) because i don't know why to use this
Re: Blockly examples
Posted: Wednesday 29 April 2015 21:09
by ThinkPad
I used a normal on/off switch for it, not the dusk/dawn type you are using. Try that
It's only a visual matter, it's about the result right
?
Re: Blockly examples
Posted: Wednesday 29 April 2015 21:10
by thecosmicgate
thecosmicgate wrote:ThinkPad wrote:I am not going to remake your event, that way you don't learn anything from it.
Some hints:
- You need to check every device/switch separately, see also below
- You are not using the 'AND' in the correct way. Use it like this: [lamp1 = On] AND [lamp2 = On].... Not like: lamp1 AND lamp2 = On... won't work
- You are now checking for the EXACT moment of sunset/sunrise. So one minute before/after sunset/sunrise the condition isn't valid anymore
Check the previous pages of this topic for inspiration/guidelines
more like this :
I'am busy with the : zon op (licht), zon onder (donker) ( Sunrise : light , Sunset Dark) blocky , first i'am reading a lot about the possibilities .
should i use Json script (as found on tweakers.net), or just use al blocky example
But how is it possible to create this blocky to learn : when whe arrive at home the light levels up ( %) ?
now made the combination with the : is dark switch :
Could somebody tell me if this is okay and working
Re: Blockly examples
Posted: Thursday 30 April 2015 18:59
by leby
you can't have the or between two switches, need to set up two separate comparisons. (the two phones)
Re: Blockly examples
Posted: Thursday 30 April 2015 19:12
by thecosmicgate
leby wrote:you can't have the or between two switches, need to set up two separate comparisons. (the two phones)
Maybe better to make a special (iemand thuis / anybody home) switch ?
I don't exactely understand understand / know how to (easy) make to separate comparisons in this blockly
Re: Blockly examples
Posted: Thursday 30 April 2015 19:32
by ThinkPad
A 'SomeoneHome' switch is easier, i also use it that way:
http://www.domoticz.com/forum/viewtopic ... 521#p27521
Re: Blockly examples
Posted: Thursday 30 April 2015 20:57
by thecosmicgate
Done
But could you maybe explain a little bit about : variable that you use in the Switch on lights when we are home, and it is getting dark and Turn on lights when we arrive home and it is dark outside blocky you use .
I tried the wiki but don't understand exactely what this variable do and mean .
Re: Blockly examples
Posted: Saturday 02 May 2015 15:59
by thecosmicgate
thecosmicgate wrote:
Done
But could you maybe explain a little bit about : variable that you use in the Switch on lights when we are home, and it is getting dark and Turn on lights when we arrive home and it is dark outside blocky you use .
I tried the wiki but don't understand exactely what this variable do and mean .
Can anybody tell or help me a little bit more about the variable option ?
Re: Blockly examples
Posted: Sunday 10 May 2015 0:09
by floris74
floris74 wrote:leby wrote:Think you need a little bit of lua.. I use a lua script to know how long time have passed since my motion sensor was breached, guess you can exchange the motion sensor with a dummy switch that is turned on when you have >3500 lux.
1) Create o dummy switch
2) Create one user variable named "Dummy switch time" give it a start value of say '1'
3) Make a blockly event that turns on the dummy switch when the sensor is >3500 lux and off if sensor is <3400
4) Add the script below to the script folder
5) now you can build your event and trigger on the value of the variable "Dummy switch time" (for example if its more than 120 or what ever)
Code: Select all
commandArray = {}
t1 = os.time()
t2 = uservariables['Dummy switch time']
r0 = t1-t2
commandArray['Variable:Timewithmorethan3500'] = tostring(r0)
print('Timewithmorethan3500 ' .. r0)
return commandArray
Think this i principle should work with your scenario..
Thanks. i hope i can use this the next days..
Floris
Sorry, but i get lost at step 3. do i need to edit the lua? what kind of lua must it be?
tnx Floris
edit: i have a variable named screen sun (must be switched to 1 after 2 minutes of sun(30000>lux)) and screen cloud (must be switched to 1 after 15 min of beiing cloud (29000 < lux))
i cant upload a picture?
Re: Blockly examples
Posted: Monday 11 May 2015 21:44
by h143
I have the follow blocky to control the humidity in the batroom
- Blocky badkamer.jpg (106.31 KiB) Viewed 8773 times
when the receiver from the ventilator miss the signal domoticz send it 5 seconds later again
i have make the variable in the blocky so i can always overule by the manual switch
Re: Blockly examples
Posted: Tuesday 12 May 2015 10:36
by ThinkPad
Looks good
Is the sensor updating fast enough? So you don't have your shower steaming for 5 minutes until the fan turns on?
Re: Blockly examples
Posted: Tuesday 12 May 2015 14:13
by RichardBokker
Why is this not working?
i want to detect MaxValue of Usage (yes i know, i can see 24h log), but i want it in a variable.
So i made an UserVariable "VermogenMax" integer. I i'm checking if VermogenMax is smaller then the usage, if so, then save the actual value in VermogenMax. But the value stay's 0.
i tried to use a dummy device, type Usage, is also not working
Another question, how can i add VermogenMax (uservariable) to a roomplan? In order to show the value on frontpage.html.
Re: Blockly examples
Posted: Tuesday 12 May 2015 19:32
by ThinkPad
thecosmicgate wrote:
Done
But could you maybe explain a little bit about : variable that you use in the Switch on lights when we are home, and it is getting dark and Turn on lights when we arrive home and it is dark outside blocky you use .
I tried the wiki but don't understand exactely what this variable do and mean .
Sorry, didn't see your post.
The var is so that when you turn the lights off, they don't turn on directly again (because the conditions are then all valid again). I reset the var at 00:01 or so i thought.
But i don't use that Blockly anymore, i now use the ABST-604 dusk/dawn sensor together with
this script.