Blockly examples

Moderator: leecollings

Post Reply
LanWolf
Posts: 36
Joined: Wednesday 20 August 2014 10:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by LanWolf »

drdracer wrote:Hello,

I made my first blocky for the following scenario: Outside temp is below 3°C and humdity is above 60%,
so the heater has to turn on. When the temperature is above 3°C and humdity is below 60%, the heater should turn off again.

Is this approach correct?
Capture.PNG
Should be okay, but i would give it more space between the on and off, because when it is just arround 3 degrees it wil go off and on quickly.
Maybe overcome that with on below 3c /60% and switch off above 4c / 58%
*/ Just A Byte /*
leechguy
Posts: 1
Joined: Sunday 21 September 2014 23:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by leechguy »

drdracer wrote:Hello,

I made my first blocky for the following scenario: Outside temp is below 3°C and humdity is above 60%,
so the heater has to turn on. When the temperature is above 3°C and humdity is below 60%, the heater should turn off again.

Is this approach correct?
Capture.PNG
I think what you want is "When the temperature is above 3°C or humidity is below 60%, the heater should turn off again."

Let's assume it is below 3°C and humdity is above 60%, your heater is now on. All of a sudden it starts to rain and the temperature rises to 6°C. In the case you use an 'and', then your heater will not turn off. The temperature may now be above 3°C, but due to the rain the humidity will be well above 60%, so the Aussen hum <= 60 will be false.

The same for humidity. If the temp. stays below 3 degrees Celsius and the humidity drops to 40%, when using an 'and' the heater will not turn off.
fredclo
Posts: 3
Joined: Thursday 18 July 2013 19:16
Target OS: -
Domoticz version:
Location: Paris
Contact:

Re: Blockly examples

Post by fredclo »

Do you know a very good API : http://api.domogeek.fr/static/index.html

It's very useful for us to know if we are a day in schoolholiday, or in public holiday...
If You enter in your browser this :

http://api.domogeek.fr/holiday/now

you have your result.

Unfortunately, in blockly I don't know how to do that : if http://api.domogeek.fr/holiday/now = "False" Do ....
doesn't work.
And you ?
fred
Raspberri Pi B+ & Domoticz. Rfxtrx USB. Chacon Magnet sensor, Karotz, teleinfo serial, FM multi room, ON/OFF 433.92 Mhz, blinds...
http://fredclo.free.fr
Morcegolas
Posts: 24
Joined: Wednesday 01 October 2014 12:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Morcegolas »

Hi, I started with domoticz last week and I'm loving it. Have a lot of questions but I think thats normal. So my problem, I'm trying to do an event that get this done:

If my door is open for more than 1 minute send a notification. This looks quite easy, but it seams to me that blocky can't help me with this one.
But lets see what you have to say. Here's what I've tried, but it only works without the timer, that I know that its wrong, but I don't see another options. :/

Image
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Blockly examples

Post by bing69 »

Morcegolas wrote:Hi, I started with domoticz last week and I'm loving it. Have a lot of questions but I think thats normal. So my problem, I'm trying to do an event that get this done:

If my door is open for more than 1 minute send a notification. This looks quite easy, but it seams to me that blocky can't help me with this one.
But lets see what you have to say. Here's what I've tried, but it only works without the timer, that I know that its wrong, but I don't see another options. :/

Image

I think you need to save the time to open the door in a var. Then you need to compare the current time with the time saved.
Morcegolas
Posts: 24
Joined: Wednesday 01 October 2014 12:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Morcegolas »

Bing69 can you get me some help doing that?
joske522
Posts: 18
Joined: Friday 19 September 2014 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by joske522 »

Hi guys, I would like to start using Blockly but nothing I try seems to work...

Just made a simple blockly set up to test if it works, but even this doesn't:
Schermafbeelding 2014-10-03 om 08.38.41.png
Schermafbeelding 2014-10-03 om 08.38.41.png (16.06 KiB) Viewed 14388 times
Is there anything you should do besides click save in the Blockly editor? (I clicked active too)

Do I need to put the freshly created Blockly in devices or switches or something like that?

Thanks!
LanWolf
Posts: 36
Joined: Wednesday 20 August 2014 10:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by LanWolf »

I don't know for sure if this works without the "else" because this is a "if else" start block.
Try a "if do" block works first.

Maybe the open should be "on" ? (seen that before, sensor sends an "on" command and due to setting the switch to doorsensor it is just shown as open)

dit you enable "events" in the application settings ?
*/ Just A Byte /*
joske522
Posts: 18
Joined: Friday 19 September 2014 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by joske522 »

LanWolf wrote:I don't know for sure if this works without the "else" because this is a "if else" start block.
Try a "if do" block works first.

Maybe the open should be "on" ? (seen that before, sensor sends an "on" command and due to setting the switch to doorsensor it is just shown as open)

dit you enable "events" in the application settings ?
Hi LanWolf,

thanks! The If Do block works like a charm! Thanks for the tip! :D
cazadeis
Posts: 5
Joined: Tuesday 24 June 2014 19:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by cazadeis »

bletellier wrote:Hi, I have a very simple need ans also simple to understand.
When there is too much wind => I want the blinds go up to not be damaged.

I try this event:
QuestionEventsBlockly_01.gif
If the wind is stronger than 2.5 m / s then up blinds

=> but it does not work

But it seems that my device "Vent" (wind) does not give a value but a string
with 6 values separated by semicolon (;)
QuestionEventsBlockly_03.gif
Questions:
1) Is it possible to recover only the value "speed" of this device "Vent" ?
2) Is it possible with a LUA script to create objects (virtual) that can be found in "Blockly" ?

Thanks.
Hello,

no idea for this problem ?

Thanks
D'rMorris
Posts: 138
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: Blockly examples

Post by D'rMorris »

Please read this.

Regarding your second question, yes this is possible. Not with the script referenced in the link above, so you'll have to add some coding for that. More info about that here.
anconakip
Posts: 17
Joined: Tuesday 30 September 2014 12:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 7722
Contact:

Re: Blockly examples

Post by anconakip »

i want to make an event that starts to look if my door is open for more than 5 minutes then my heating is going of.
I only don't know how i can start the scene "if door=open for more than 5 minutes"
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 »

Not sure if this would work:-

Create a Virtual Switch with a 5 minute "ON Delay" setting.

IF Door = "Open"
DO Set "Virtual Switch" "On"

ELSE IF Door = "Closed"
DO Set "Virtula Switch" "Off"

So the "Virtual Switch" although set to "on" by Blockly, has a 5 minute delay before the state is actually set. If the door is closed meantime then hopefully (not sure if this will happen) the "Off" switch state is selected cancelling the "On Delay".
If that is the case then you can use the Virtual Switch state with your heating control logic. Worth a try?
anconakip
Posts: 17
Joined: Tuesday 30 September 2014 12:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 7722
Contact:

Re: Blockly examples

Post by anconakip »

StanHD wrote:Not sure if this would work:-

Create a Virtual Switch with a 5 minute "ON Delay" setting.

IF Door = "Open"
DO Set "Virtual Switch" "On"

ELSE IF Door = "Closed"
DO Set "Virtula Switch" "Off"

So the "Virtual Switch" although set to "on" by Blockly, has a 5 minute delay before the state is actually set. If the door is closed meantime then hopefully (not sure if this will happen) the "Off" switch state is selected cancelling the "On Delay".
If that is the case then you can use the Virtual Switch state with your heating control logic. Worth a try?
No,
sorry. It doesn't work. The dummy switch does not turn of when the door is closed within the 5 minutes.
DaaNMaGeDDoN
Posts: 55
Joined: Thursday 23 October 2014 19:01
Target OS: Linux
Domoticz version: beta
Location: Eindhoven, the Netherlands
Contact:

Re: Blockly examples

Post by DaaNMaGeDDoN »

Hi all, first a big thumbs up for domoticz, i have been playing around with it for some time now and must say i love it! Great work!
However i am currently struggling with understanding the logic of the "IF DO ELSE IF DO..." control blocks.
Note this is different from the IF-DO block which works as expected: IF (condition) DO (action)...simple. I can best illustrate my problem with the following:
I have a floorheater pump that is controlled by a kika like switch, works.
I wish to have the floorheater pump turned off when the outside temperature rises above a certain level. I wish it to be on below a certain level OR at least run for 20 minutes daily.
What i came up with is attached. I intentionally left out the evaluation to only turn it on if its not turned on already because that would trigger trigger the second evaluation immediately after it had been turned on.
The problem: the second evaluation (ELSE IF "PUMP=ON") counts even when its below the 17 degrees, or time is within that interval specified in the first evaluation. I would expect the second condition only to be evaluated IF the first condition is not met/true. What happens now (temperature outside well below 17 degrees) if it is switched on it immediately is switched off. It seems like it will evaluate the second condition even if the first one is true.

What have i overlooked here? The behavior i am seeing now is like having 2 separate IF DO blocks, not IF DO ELSE IF.
Thanks for any help/thoughts.
A lua script wont work here: i am both triggering based on both time of the day and device status.
I am using the current stable.

PS: I think i read somewhere IF DO ELSE (no second IF) were not possible by design. Can we work around that by using these IF DO ELSE IF blocks with a second condition that is always true? I have to admit i have tried that but have not found anything that works (like with a IF 1==1 like condition), maybe that is related to what i am not seeing correctly here??
Attachments
floorheaterpumpcontrol.PNG
floorheaterpumpcontrol.PNG (45.95 KiB) Viewed 14137 times
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Blockly examples

Post by simonrg »

I am not quite sure why you can't use Lua - you can't have a script which is triggered on both time and a device, but two scripts which talk to each other via a dummy switch allows for both.

Personally I don't think Blockly is easy once you get to this level of complexity.
DaaNMaGeDDoN wrote:I wish to have the floorheater pump turned off when the outside temperature rises above a certain level. I wish it to be on below a certain level
script_device_pumptemp.lua - script triggered by when temperature changes - if high switch off (if dummy override switch is not on), if low switch on - what you can also do is measure the length of the time the pump is on for and keep a running total for one day in a uservariable.
DaaNMaGeDDoN wrote:OR at least run for 20 minutes daily.
script_time_pumptemp.lua - script switches pump on at 16:00 if cumulative pump on time for the day is less than 20 minutes then switches pump on for enough time to make up 20 minutes, calculate stop time and stores in uservariable, switches on a dummy override switch, always resetting cumulative pump on time to zero. Script then switches off at time in uservariable, turns off dummy switch.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
DaaNMaGeDDoN
Posts: 55
Joined: Thursday 23 October 2014 19:01
Target OS: Linux
Domoticz version: beta
Location: Eindhoven, the Netherlands
Contact:

Re: Blockly examples

Post by DaaNMaGeDDoN »

I think i resolved it, using lua, hope i am not going off-topic here.
I started off with 2 scripts like suggested by simonrg above.
During that i found the data for the weather station i use is updated every 10 minutes and also because i preferred to keep it all in one script i decided to use a different approach and created one script that is triggered by time (or better: ran every minute). Simonrg's suggestion about the shared variable inspired me. What i came up with is below. The idea is a uservar gets reset every day at 5am and decremented every minute the pump is on until its 0. If the next day at 4am the uservar is above 0 and the pump isnt running, it turns it on. Only if the temperature allows for it and the uservar has been decremented till 0, the pump will be turned off.
The only downside to this approach is 30 entries in the log every minute from 4:00am when its making up for the time it hasnt run and the uservar is decremented.
Its basically now a set of 4 "if-do" rules that are pretty self-explanatory when you see it below (i added some comments). I have not been able to test it extensively yet but i feel pretty confident this will work.

Code: Select all

commandArray = {}
time=os.date("*t")

if (otherdevices['Kitchen Floorheater pump'] == 'On' and uservariables['floorheaterpumpminruntime'] > 0)
then --if the pump is on decrement the floorheaterpumpminruntime uservar, but not below 0.
	commandArray['Variable:floorheaterpumpminruntime']=tostring(uservariables['floorheaterpumpminruntime']-1)
end

if (otherdevices_temperature['WU Bennekel Temp'] > 17 and otherdevices['Kitchen Floorheater pump'] == 'On' and uservariables['floorheaterpumpminruntime'] == 0 )
then --if temp > 17, pump is on and minimum runtime has been reached: turn pump off.
	commandArray['Kitchen Floorheater pump']='Off'
end

if (otherdevices_temperature['WU Bennekel Temp'] <= 17 and otherdevices['Kitchen Floorheater pump'] == 'Off')
then --if temp < 17 and pump is off turn pump on.
	commandArray['Kitchen Floorheater pump']='On'
end

if (time.hour == 4 and time.min == 0 and uservariables['floorheaterpumpminruntime'] > 0 and otherdevices['Kitchen Floorheater pump'] == 'Off')
then --if its 4:00, minimum pump runtime has not been reached and the pump is off: turn it on.
	commandArray['Kitchen Floorheater pump']="On"
end

if (time.hour == 5 and time.min == 0)
then --if its 5:00 reset the floorheaterpumpminruntime uservar to 30.
	commandArray['Variable:floorheaterpumpminruntime']='30'
end

return commandArray
Thanks for the input.
User avatar
mvveelen
Posts: 678
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Blockly examples

Post by mvveelen »

ErikCramer wrote:
gibbiem wrote:Hi, I have a question about the first and last post on this thread.

On the first, the person posted an example of a blocky where there is an 'if,do' command within and an 'if,do' command. How do you get Domoticz to create this?

On the last post, the example include an 'else,if' command, I also cant find this on my system.

Just updates to .918

Thanks

Hi see my picture.

There is the option if do and the else if if you press the + sign

In domotics its Setup > more options > events.



Guess with my blocky i did some thing wrong as its dark and the light is still off.. :(
perhaps it would be nice if there would be a test option in the scripts..
Hi, did you manage to get this working?

I want to have the same thing: at (preferably 15 minutes after) Sunset I want my lights in the backyard to turn on. And at (15 minutes before) Sunrise I want the lights in the backyard to turn off.

I tried several things, but nothing worked. Can someone help me out and build a scene which I can copy/paste? And yes, it would be great if there was an option to test these kind of scenes.

Thanks in advance!
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
markk
Posts: 267
Joined: Tuesday 14 January 2014 14:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by markk »

Can't you use the timer on the switch?
Running Domoticz on Pi3 with RFXtrx433e. LWRF power sockets and dimmer switches. Integrated my existing wirefree alarm PIRs and door contacts with domoticz. Geofencing with Pilot. Harmony Hub. Tado for Heating. Now playing with mysensors.
User avatar
mvveelen
Posts: 678
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Blockly examples

Post by mvveelen »

Well, I can try (but I thought this wasn't possible for some reason).

I now have:

Image

Will this work?
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest