Combine switch and sensor in a single virtual switch

Moderator: leecollings

Post Reply
alfpresa
Posts: 4
Joined: Thursday 02 March 2017 18:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Combine switch and sensor in a single virtual switch

Post by alfpresa »

Hi everyone!

I've integrated an alarm system inside Domoticz by using:
- Philio PAN06 switch to control the arm and disarm of the alarm by triggering a 2 seconds pulse from each channel (1st channel pulse means arm, and the 2nd means disarm). This is needed as the module doesn't have a battery backup and I don't want the alarm to be disarmed by simply cutting my house's power wires.
- Universal Fibaro Sensor conected to the alarm output to get the armed/diarmed status. Why is this required, because the alarm might not be armed if there's a failing zone or another type of problem, so I cannot rely just on the switch working fine.

This is working perfectly but it lacks some usability as I (well... to be honest it's my wife) would expect to have a single switch that:
- When clicked from off state, triggers the alarm arming, and only transitions to "on" state when the alarm sensor reports the "on" state.
- When clicked from on state, triggers the alarm disarming process, and only transitions to "off" state when the alarm sensor reports the "off" state.

I've tried to implement this with a virtual switch and with events. I've successfully created a virtual switch that:
- When clicked from off state, triggers the alarm arming and keeps as on even when the pulse ends.
- When clicked from on state, triggers the disarm and keeps as off.

But I've not been able to block the trigger to be displayed as on/off depending on the sensor state. When trying to do so with an event, the whole system enters a loop and keeps trying to arm the alarm.

I've also been trying to use LUA but I get to the same loop.

TLDR; how do you make a switch stay off even after being activated until a sensor reports on state, and how do you make it to stay as on even after a deactivation attempt until a sensor reports off?

Any ideas or guidance will be welcome :-).

Thanks!
RayAmsterdam
Posts: 115
Joined: Sunday 11 January 2015 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Combine switch and sensor in a single virtual switch

Post by RayAmsterdam »

You could use the udevice JSON command to change the switch state without triggering it.
alfpresa
Posts: 4
Joined: Thursday 02 March 2017 18:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Combine switch and sensor in a single virtual switch

Post by alfpresa »

Ok.... That was totally it. In the on activate action of the switch force it as off, and on the on activate of the sensor set the switch to on. The other way around on the deactivate...

It's working like a charm now!

Thanks!!
eddiecharette
Posts: 2
Joined: Tuesday 31 January 2017 7:27
Target OS: -
Domoticz version:
Contact:

Re: Combine switch and sensor in a single virtual switch

Post by eddiecharette »

One can create a virtual device of desired capabilities and/or custom commands and attributes. A simple SmartApp which synchronizes attributes with the real devices would be enough.
Sometimes you may run into synchronization problems distinguishing sync events from real events. On such occasions try adding separate “virtual” commands to the virtual device.
Now, regarding the Fibaro Universal sensor, they have got many wires/inputs/outputs. I guess unisensor is not a wise choice. Unisensor outputs follow the inputs, you can add a delay, invert but won’t be able to control the outputs. When I was in a similar situation, I sought expert guidance of home alarm security system toronto. They suggested me to use Unisensor to sense Armed/Disarmed and Stay/Unstay. They also advised me to use a separate dual relay to Arm.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests