PIR Sensor, Telegram and schedule
Moderator: leecollings
-
Ritmeester
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
PIR Sensor, Telegram and schedule
I have a PIR sensor with the following Domoticz options:
It has an On Action with a script to send me a snapshot to my Telegram bot
It has Custom Message to send to my Telegram bot
All is just working fine now
How can I make this PIR sensor to send me the messages only between 23:00 and 07:00?
I look in the Switch options itself but I can’t find a solution. Do I have to make this in Blocky?
It has an On Action with a script to send me a snapshot to my Telegram bot
It has Custom Message to send to my Telegram bot
All is just working fine now
How can I make this PIR sensor to send me the messages only between 23:00 and 07:00?
I look in the Switch options itself but I can’t find a solution. Do I have to make this in Blocky?
-
georgesattali
- Posts: 84
- Joined: Saturday 05 March 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: France
- Contact:
Re: PIR Sensor, Telegram and schedule
hello,
here's some lua code, that you must test first, I cannot garantee it will work first time :
It is a "Device" script, so go to Setting / More Options / Events / Lua,
remove everything from the example and past the following code,
click "All" and choose "Device" instead of "All",
click "Event active" and save.
Of course, put the exact name of your PIR Device and copy the script call (without the leading "script://").
I recommand you keep an exact copy of the script call because you have to remove it from the PIR "On Action" (or you will receive them twice during the night).
See you,
GD
here's some lua code, that you must test first, I cannot garantee it will work first time :
It is a "Device" script, so go to Setting / More Options / Events / Lua,
remove everything from the example and past the following code,
click "All" and choose "Device" instead of "All",
click "Event active" and save.
Of course, put the exact name of your PIR Device and copy the script call (without the leading "script://").
I recommand you keep an exact copy of the script call because you have to remove it from the PIR "On Action" (or you will receive them twice during the night).
Code: Select all
commandArray = {} -- needed by dz
now = os.date("*t")
if devicechanged["Name of your PIR here"] == "On" then
-- only if after 23 or before 7
if (now.hour >= 23) or (now.hour < 07) then
os.execute("bash " .. "put script and args here without the script://")
end
end
return commandArray -- needed by dz
GD
-
Ritmeester
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: PIR Sensor, Telegram and schedule
Hi GD,
Thanks for your input. This lua script is working fine and does the job.
There is only every minut an error in the log file after the script runs one time.
Other option
My second question is why this "can’t" be working?
Thanks for your input. This lua script is working fine and does the job.
There is only every minut an error in the log file after the script runs one time.
Code: Select all
2016-07-03 14:44:00.428 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)
2016-07-03 14:45:00.458 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)
2016-07-03 14:46:00.488 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)
2016-07-03 14:47:00.018 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)
2016-07-03 14:48:00.048 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)
2016-07-03 14:49:00.079 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)
2016-07-03 14:50:00.110 Error: EventSystem: in PIR Test aanroep Script: [string "commandArray = {} -- needed by dz ..."]:5: attempt to index global 'devicechanged' (a nil value)Other option
My second question is why this "can’t" be working?
Code: Select all
2016-07-03 14:21:52.773 Error: Error opening url: script:///home/pi/domoticz/scripts/camera1.sh
Last edited by Ritmeester on Sunday 03 July 2016 17:42, edited 2 times in total.
-
Derik
- Posts: 1605
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: PIR Sensor, Telegram and schedule
I think this a "problem" with Blockley...
Some of my blockleys are switching every minute to...
Some of my blockleys are switching every minute to...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2445
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: PIR Sensor, Telegram and schedule
Change the Box under LUA from All to Devices, this will fix this error!Ritmeester wrote:Hi GD,
Thanks for your input. This lua script is working fine and does the job.
There is only every minut an error in the log file after the script runs one time.
Jos
-
Ritmeester
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: PIR Sensor, Telegram and schedule
Hi Jos,
Thanks, this did the trick.
Thanks, this did the trick.
-
Derik
- Posts: 1605
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: PIR Sensor, Telegram and schedule
I mean...jvdz wrote:Change the Box under LUA from All to Devices, this will fix this error!Ritmeester wrote:Hi GD,
Thanks for your input. This lua script is working fine and does the job.
There is only every minut an error in the log file after the script runs one time.
Jos
What is the different thing between this options?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2445
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: PIR Sensor, Telegram and schedule
@Derik, Guess the "?" means you don't know what I am trying to say? 
In the case you get the nil error for devicechanged[] table every minute on the minute, it simply means the script is ran as a TIME script as well. This happens when using the internal editor and you leave the dropdown selection box under the LUA dropdownbox on ALL as that will run the script for ALL events: Device/Time/Variable/Security events. With a Time event, the devicechanged[] table isn't generate leading to this nil error.
Making sense?
Jos
In the case you get the nil error for devicechanged[] table every minute on the minute, it simply means the script is ran as a TIME script as well. This happens when using the internal editor and you leave the dropdown selection box under the LUA dropdownbox on ALL as that will run the script for ALL events: Device/Time/Variable/Security events. With a Time event, the devicechanged[] table isn't generate leading to this nil error.
Making sense?
Jos
-
Ritmeester
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: PIR Sensor, Telegram and schedule
Thanks for the explanation.
For me this makes sense now. I hope also for @Derik
For me this makes sense now. I hope also for @Derik
Who is online
Users browsing this forum: No registered users and 1 guest