Page 1 of 3

ByronSX PIR

Posted: Thursday 09 January 2014 20:40
by fisics
Hi guys,

It seems over the past few days quite a few of us in the UK have gone out and bought lots of Siemens ByronSX PIR Chimes as they are very cheap!

http://www.diy.com/nav/fix/electrical/d ... d=11858210

They work great with Domoticz (RFXCOM Firmware 71) and you can have up to 16 thanks to the dip switches.

My understanding is that they don't send an OFF command.

Is it possible to automatically tell Domoticz to set as off after 10 seconds?

I notice there's an "On Action" script, could I use this somehow?

Thanks

Re: ByronSX PIR

Posted: Thursday 09 January 2014 21:07
by mbliek
With my marmitek ms13 I can set off after xx sec in domoticz. So is probably possible for this PIR also

Re: ByronSX PIR

Posted: Thursday 09 January 2014 22:34
by spiderrob
I think the problem is that Domoticz sees it as a 'Chime' type regardless of the switch type you actually define. I guess a chime isn't really on or off...

So, Is there anyway us guys in the UK with these Siemens PIRs can define them in Domoticz with the ability to have an 'On' or 'Off' State. They are recognised as ByronSX, Type 'Chime' but as such are always 'On' if you try and change the 'Switch type' to something else.

Re: ByronSX PIR

Posted: Friday 10 January 2014 14:35
by simonrg
I don't think there is a problem with Domoticz, as I believe the Siemens PIRs only send a "detected signal", they don't send a "not detected signal". So Domoticz just detects a series of "detected signals" which it reports as On. Some PIRs do send a "not detected signal" after a set length of time which is set on the PIR itself, you can use blocky to simulate a more complex PIR - as niki_lauda demonstrates in the "Timed motion sensor" thread.

I have found it best to set the PIRs as on/off switches and then use a piece of blocky to control the actions - the PIR sends an "detected signal" (On) which triggers blocky to turn the PIR Off and then turn something on for a length of time, the example below turns my study light on for 1 minute, so the light will go off 1 minute after the last motion is detected by the PIR.
Blocky code example for a PIR.
Blocky code example for a PIR.
PIRblocky.jpg (11.93 KiB) Viewed 12169 times
PIRs for only £5 are a real steal and so far work really well.

Re: ByronSX PIR

Posted: Friday 10 January 2014 14:55
by spiderrob
Simon - Are you using the Siemens PIRs? Even if I set them as on/off switches, they do not turn off - Ie you can't even turn them off by clicking the device.

Re: ByronSX PIR

Posted: Friday 10 January 2014 16:33
by simonrg
Rob - I am using the Siemens PIRs - I can't switch them off either, however what counts is not getting a "detected signal" - I have now left the PIR1 = Off line out of the blocky script and still works. It appears that Domoticz is smart enough to know that this is PIR and can only send a "detected signal", so doesn't respond. However, I can confirm that the blocky script does what it says on the can, i.e. if I either activate the PIR or click on the on/off icon then my study light comes on and goes out 1 minute after the green light on the PIR goes out. I have now set the PIR as a motion sensor in Domoticz, this seems to make most sense.

Re: ByronSX PIR

Posted: Friday 10 January 2014 16:46
by Derik

Re: ByronSX PIR

Posted: Friday 10 January 2014 17:01
by simonrg
The Siemens PIR sensors seems to well behaved, using the ByronSX protocol rather than AC. They appear to only send a short signal, as I get multiple events in a few seconds and still get other signals detected:
  • Fri Jan 10 15:57:10 2014 (RFXCOM) Temperature (Understairs)
    Fri Jan 10 15:57:10 2014 (RFXCOM) Humidity (Understairs)
    Fri Jan 10 15:57:11 2014 (RFXCOM) Current Meter (Owl)
    Fri Jan 10 15:57:11 2014 (RFXCOM) Temperature (Attic)
    Fri Jan 10 15:57:12 2014 (RFXCOM) Humidity (Attic)
    Script event triggered: /home/pi/domoticz/scripts/lua/script_device_alwayson.lua
    Fri Jan 10 15:57:30 2014 (System) Temperature (RaspberryPi)
    Fri Jan 10 15:57:31 2014 (RFXCOM) Lighting 5 (Router)
    Fri Jan 10 15:57:32 2014 (RFXCOM) Receiver/Transmitter Message
    subtype = Transmitter Response
    Sequence nbr = 174
    response = ACK, data correct transmitted
    UI Event triggered: PIRTest_1
    Fri Jan 10 15:57:33 2014 (RFXCOM) Chime (Bath PIR)
    Fri Jan 10 15:57:34 2014 (RFXCOM) Lighting 5 (Bathroom)
    Fri Jan 10 15:57:35 2014 (RFXCOM) Receiver/Transmitter Message
    subtype = Transmitter Response
    Sequence nbr = 175
    response = ACK, data correct transmitted
    Fri Jan 10 15:57:37 2014 (RFXCOM) Chime (Bath PIR)
    Fri Jan 10 15:57:41 2014 (RFXCOM) Current Meter (Owl)
    Fri Jan 10 15:57:41 2014 (RFXCOM) Chime (Bath PIR)
    Fri Jan 10 15:57:45 2014 (RFXCOM) Chime (Bath PIR)
    Script event triggered: /home/pi/domoticz/scripts/lua/script_device_alwayson.lua
    Fri Jan 10 15:58:00 2014 (System) Temperature (RaspberryPi)
    Fri Jan 10 15:58:01 2014 (RFXCOM) Receiver/Transmitter Message
    subtype = Transmitter Response
    Sequence nbr = 176
    response = ACK, data correct transmitted
    Fri Jan 10 15:58:08 2014 (RFXCOM) Humidity (Understairs)
    Fri Jan 10 15:58:09 2014 (RFXCOM) Temperature (Attic)
    Fri Jan 10 15:58:09 2014 (RFXCOM) Humidity (Attic)
    Fri Jan 10 15:58:11 2014 (RFXCOM) Current Meter (Owl)
    Fri Jan 10 15:58:14 2014 (RFXCOM) Temperature (Verandah)
So don't seem to block RF reception for 10s of seconds as the AC protocol based detectors do.

Re: ByronSX PIR

Posted: Monday 13 January 2014 10:35
by simonrg
I have a couple of practical challenges with using these PIRs with Domoticz, am I missing, is there a better way to set these up.

Basically, because Domoticz knows it has already turned on a light on for x minutes, if the PIR is activated within the x minutes, then Domoticz ignores the Set On For command as the light is already on. Fine in principle.

However, if the PIR is activated at x minutes minus 1 second, then the light will still go out at x minutes, and will not come back on again until the PIR is reactivated. What I had hoped would happen is that light would stay on for x minutes after last activation, not first within x minutes.

Other challenge is using LightwaveRF switches, means that if the light is switched off manually, then you want the PIR to turn the light on within the x minutes, it won't as Domoticz thinks the light is still on and so won't send a further on signal until the x minutes is finished.

Is there a way I can achieve the behaviour I want, light stays on for x minutes after last PIR activation and Domoticz sends the On Signal whenever the PIR is activated so that it turns the light again within the x minutes if switched off manually?

Re: ByronSX PIR

Posted: Monday 13 January 2014 11:04
by Keptenkurk
Simon,
I think that a Lua script is the way to go at this moment.
This example appears to do at least some of what you're trying to do.

[offtopic] I ran into this same requirement: the need for "On for x minutes" with retrigger.
I found out that the pump of my floor heating runs 7x24 at 60W even if there is no heating at all.
Now i want the pump to run only 60 minutes after the thermostat has last switched on (and 15 minutes every day). Will put it into Lua like the example mentioned.
And the calculated savings of € 50/yr go straight into the Domoticz Business Case :-)
/paul

Re: ByronSX PIR

Posted: Tuesday 14 January 2014 17:27
by simonrg
Thanks for pointers, a little bit different as the Siemens pir only ever return detected, they don't return not detected.

Compared to Blocky, LUA will turn devices on again, when they have been manually turned off and the light finally goes off a time after last activation, not a time after first activation.

So, using LUA I have managed to achieve what I wanted to, I have written two general scripts which interact with the Siemens wirefree pirs named as "PIR room name" and control light switches called "room name".

The first script waits for any devices called "PIR room name" to change when seen then "room name" will switch on:

Code: Select all

commandArray = {}

tc=next(devicechanged)
v=tostring(tc)
if (v:sub(1,3) == 'PIR') then
   c=tostring(v):sub(5)
   commandArray[c] = 'On'
   tmess = c..' Light On - time 0'
   print(tmess)
end

return commandArray
Fairly simiple, checks to see if the device changed starts with PIR, if so then strips off "PIR " and turns on "room name" and prints a little message to say that that light has switched on.

The second script is a timer script which checks through each device to find all the Siemens pirs to see how long ago each pir was last turned on and switches the light off if more than 4 minutes ago:

Code: Select all

function timedifference(s)
   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)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=se$
   difference = os.difftime (t1, t2)
   return difference
end

commandArray = {}

for i, v in pairs(otherdevices) do
   tc = tostring(i)
   v = i:sub(1,3)
   if (v == 'PIR') then
      difference = timedifference(otherdevices_lastupdate[tc])
      if (difference > 239 and difference < 320) then
         tempdiff = tostring(difference)
         c = i:sub(5)
         tempmessage = c.." Light Off - at least 240 secs up - actually - " .. $
         print(tempmessage)
         commandArray[c] = 'Off'
      end
   end
end

return commandArray
A little bit more complex script, firstly time difference function taken from previous posts (thanks). Then test each other device and see if it is a PIR, if it is then see if it changed between 4 and 5 minutes ago, if so then switch off "room name" and put a message in the log.

Current final bit is to have pirs PIR Bathroom, PIR Shower and light switches Bathroom, Shower which work fine, then when I get more I just add Siemens pir PIR Utility and light switch Utility which will just magically work.

I am not sure this is the best way to do it, but it works, any suggestions for a simpler, less resource intensive or just smarter way would be most welcome.

Re: ByronSX PIR

Posted: Wednesday 15 January 2014 0:47
by commodore white
I managed to nab 8 of these beauties. Perfect for the new house. Though they report chime, I've configured them as motion sensors. I also configured them to turnoff after 30 but this doesn't work. Is this as expected?

Re: ByronSX PIR

Posted: Wednesday 15 January 2014 8:35
by simonrg
How did you configure them to turn off after 30 minutes, did you set the "Off Delay" in Domoticz? I think this means that after a "not detected" signal is recieved then wait x seconds before switching off. The problem is the Siemens wirefree pirs don't send a "not detected" signal, hence the need to write the scripts I posted in the previous post.

Re: ByronSX PIR

Posted: Wednesday 15 January 2014 12:21
by kylegordon
I'm not sure what the "Off Delay" is supposed to do. Maybe it's the length of time Domoticz waits before considering the Motion Sensor as "Off" - but that's not the case as I've tried setting it to 30 seconds, and although the light has gone off on the PIR, Domoticz still says it's "On" 12 hours later :-) It might be an internal timer that's used to send the Off command to devices that are actioned by it.

I use the following Blockly snippets to turn a real PIR (PIR1_Device) into a "virtual" PIR (PIR1) that's on for 1 minute. The PIR1_Device has "Off Delay" set to 0, and PIR1 Device is on a Dummy transceiver.
Blockly PIR Auto Off.png
Blockly PIR Auto Off.png (12.39 KiB) Viewed 11959 times
And the following Blockly is a light that relies on the PIR
Blockly PIR Action.png
Blockly PIR Action.png (13.26 KiB) Viewed 11959 times
It all seems to work :-)

Re: ByronSX PIR

Posted: Wednesday 15 January 2014 13:14
by simonrg
Great nice approach to overcome the limitation of the Siemen's pirs and how Blockly works.

I think you are correct the "Off Delay" is the time Domoticz would wait after it recieved an "off signal", to give you time to leave the room before being plunged into darkness. The problem is that the Siemen's pirs don't send an off signal, they only send an on signal, then don't send anything until they next send an on signal, so the log in Domoticz shows each on signal recieved, but never shows an off signal.

I like the way you have used a virtual PIR to simulate what a more intelligent PIR would do, i.e. send an off signal if not activated for a set length of time.

The problem I was having combining the Siemen's PIRs with LightwaveRF lights using Blockly was that the LightwaveRF lights can be turned off mechanically by the switch, so Domoticz still thinks the light is on and Blockly won't send another on signal until the 1 minute is up even though the light is now physically off.

The other issue was for a shower room setting the time to 5 minutes, with Blockly the 5 minutes was from when you first entered the room, not from when movement was last detected, so the light always goes out before Blockly turns it back on. With LUA I have managed to set it up so the light stays on for 5 minutes after last movement detected.

Re: ByronSX PIR

Posted: Wednesday 15 January 2014 15:56
by CopyCatz
Image

I use the off delay on my kaku sensors, they go to "off" just fine. I guess what it doesn't do is switch an associated lamp, it's more of a status reset. If you set the off delay to 0, the sensor status will stay on and domoticz will probably not regard the next trigger as such (from on to on is not a change).

Re: ByronSX PIR

Posted: Wednesday 15 January 2014 17:07
by simonrg
Either the Kaku PIRs work differently to the Siemens PIRs or there is something broken in the ByronSX protocol. I know that the standard LightwaveRF pir has a timer on it that sends an off signal after the set time and hence can switch off a light directly. My hypothesis was that the Siemens PIRs were unique in only sending On signals as they are designed to be paired with a doorbell and hence only signal on to the doorbell to make it ring. I had assumed that all other pirs sent an off signal and hence the delay time was to give a delay before status change to off having recieved the off signal.

Forgetting about switching any light and just focussing on the functionality of the PIRs, as you can see in the screen capture below, I seem to have the same settings as you for the pir, but as the graph at the bottom shows the pir status never goes to Off.
140115PIRLogs.jpg
140115PIRLogs.jpg (46.79 KiB) Viewed 11935 times
For the Kaku sensors does the log show Off signals recieved or is it just the graph that shows a status change to off?

Luckily as Domoticz / LUA spots each activation of the PIR as a device change, I am able to use the PIR, so please don't change that behaviour.

Re: ByronSX PIR

Posted: Saturday 18 January 2014 9:27
by fisics
Hi guys,

I thought my solution to turning these off could have been to make a simple "On Action" script that after 10 seconds sends a JSON URL to Domoticz with the off command.


#!/bin/bash

sleep 10

http://10.0.1.20:8080/json.htm?type=com ... tchcmd=Off


However, it seems that as they are setup as "Chimes" there is no ON/OFF just ON state.

How can we allow Domoticz to allow these "BryonSX Chimes" as ON or OFF?

Thanks

Re: ByronSX PIR

Posted: Saturday 18 January 2014 9:57
by simonrg
I don't think it is appropriate for Domoticz to make a special case for these, the ByronSX PIRs only send an "on" signal, so really act as doorbells rather than classic pirs which send both "off" and "on" signals.

So use of Blockly, LUA or a Bash script connecting the ByronSX PIRs to lights / other devices seem the correct way to go.

Re: ByronSX PIR

Posted: Sunday 19 January 2014 22:36
by windriverski
simonrg wrote:

Code: Select all

   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=se$



         tempmessage = c.." Light Off - at least 240 secs up - actually - " .. $
@simonrg -- Great bit of code, the first script works well, but I think the 2nd script has issues with wordwrap on here ($) at end of line