Door open blockly troubles
Moderator: leecollings
-
- Posts: 65
- Joined: Monday 21 August 2017 19:52
- Target OS: Windows
- Domoticz version: 3.8153
- Location: Rhoon
- Contact:
Door open blockly troubles
Trying to get the following working: If the front door is open for longer then 1 minute, play a sound thru the Xiaomi gateway en send an alert.
These are my blockly's: As I don't want an alert everytime the door is opened for a short time, I first set a trigger when the door is open for a longer period (for test sake 10 seconds).
If I just use this script, the 'Door open switch' is triggered after 10 seconds.
Then the actual action : I get a notification that the door is open, but the 'Door open switch' doesn't get triggered anymore, I see that the Xiaomi Gateway Doorbell is triggered, but get no sound. I do get the notification that the door is open, but not that it is closed again when I close the testdoor again.
Doing something wrong, but what?
These are my blockly's: As I don't want an alert everytime the door is opened for a short time, I first set a trigger when the door is open for a longer period (for test sake 10 seconds).
If I just use this script, the 'Door open switch' is triggered after 10 seconds.
Then the actual action : I get a notification that the door is open, but the 'Door open switch' doesn't get triggered anymore, I see that the Xiaomi Gateway Doorbell is triggered, but get no sound. I do get the notification that the door is open, but not that it is closed again when I close the testdoor again.
Doing something wrong, but what?
-
- Posts: 65
- Joined: Monday 21 August 2017 19:52
- Target OS: Windows
- Domoticz version: 3.8153
- Location: Rhoon
- Contact:
Re: Door open blockly troubles
No one a clue?
-
- Posts: 55
- Joined: Saturday 05 March 2016 21:42
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.5629
- Contact:
Re: Door open blockly troubles
In the test you set the door open switch.
If door open set door open switch.
In your second script you have...
If door sensor open AND switch open.
THEN
This situation does not exist because you do not set the switch to open like in the first working script.
I am not an expert. Hope it helps
If door open set door open switch.
In your second script you have...
If door sensor open AND switch open.
THEN
This situation does not exist because you do not set the switch to open like in the first working script.
I am not an expert. Hope it helps
Rp3, youlesss, rfxcom, philips hue, dsb1820
-
- Posts: 65
- Joined: Monday 21 August 2017 19:52
- Target OS: Windows
- Domoticz version: 3.8153
- Location: Rhoon
- Contact:
Re: Door open blockly troubles
Thanks! Totally looked over that. Removed the "Door sensor Test'= open from the second script, now it works!
-
- Posts: 81
- Joined: Thursday 10 December 2015 0:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: Door open blockly troubles
Still this will not work, because the door open switch will be set to 'On' after 10 seconds anyway, even if you close the door before the 10 seconds have passed. Instead you should use a time script.
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: Door open blockly troubles
I have done this in Lua. See the Lua GarageDoor example.. in the wiki
-
- Posts: 65
- Joined: Monday 21 August 2017 19:52
- Target OS: Windows
- Domoticz version: 3.8153
- Location: Rhoon
- Contact:
Re: Door open blockly troubles
@slinkos: Found that out...
Can you tell me more about a good time script for this?
@freijn: Thanks, I'll look into that!

@freijn: Thanks, I'll look into that!
-
- Posts: 81
- Joined: Thursday 10 December 2015 0:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: Door open blockly troubles
Yes, with the GarageDoor example as freijn says. So in your case it would look like this:
What this does, is that it compares the last update time of your switch, with the current time. If that is more than 10 seconds, it will send you a notification. The <20 is so that you only get notificated once, because 20/30/40/whatever seconds is also more than 10.
Now there is a problem with this script, because it runs every minute, there's a good chance that by the time it runs, the last update is more than 20 seconds in the past. So you should consider in changing your "less than value" to < 65 seconds, that's the minimum for this to work.
Here's your code that should work:
Code: Select all
-- script_time_dooropen.lua
t1 = os.time()
s = otherdevices_lastupdate['Door open switch']
-- returns a date time like 2013-07-11 17:23:12
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
commandArray = {}
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (otherdevices['Door open switch'] == 'On' and difference > 10 and difference < 20) then
commandArray['SendNotification']='Door is open#Door is open for more than 10 seconds!'
print("Door is open")
end
return commandArray
Now there is a problem with this script, because it runs every minute, there's a good chance that by the time it runs, the last update is more than 20 seconds in the past. So you should consider in changing your "less than value" to < 65 seconds, that's the minimum for this to work.
Here's your code that should work:
Code: Select all
-- script_time_dooropen.lua
t1 = os.time()
s = otherdevices_lastupdate['Door open switch']
-- returns a date time like 2013-07-11 17:23:12
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
commandArray = {}
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (otherdevices['Door open switch'] == 'On' and difference > 10 and difference < 65) then
commandArray['SendNotification']='Door is open#Door is open for more than 10 seconds!'
print("Door is open")
end
return commandArray
Last edited by Slinkos on Tuesday 24 October 2017 23:21, edited 1 time in total.
-
- Posts: 81
- Joined: Thursday 10 December 2015 0:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: Door open blockly troubles
Actually, I used your "Door open switch" in my example. But you no longer need to use that switch off course. You should just change that to the name of your door sensor. And maybe replace 'On' with 'Open'.
-
- Posts: 65
- Joined: Monday 21 August 2017 19:52
- Target OS: Windows
- Domoticz version: 3.8153
- Location: Rhoon
- Contact:
Re: Door open blockly troubles
Thanks for the help! I tested it, but I don't get a message after 60 seconds. Where should this be send to? In the log?
And preferably, I would like it that a switch is actually triggered, so I can work with this switch in Blockly
And preferably, I would like it that a switch is actually triggered, so I can work with this switch in Blockly
-
- Posts: 81
- Joined: Thursday 10 December 2015 0:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.4834
- Location: Netherlands
- Contact:
Re: Door open blockly troubles
Code: Select all
commandArray['SendNotification']='Door is open#Door is open for more than 10 seconds!'
Code: Select all
print("Door is open")
Who is online
Users browsing this forum: No registered users and 1 guest