Door Sensor as a single switch

ljoncz
Posts: 3
Joined: Thursday 12 January 2017 11:15
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Door Sensor as a single switch

Postby ljoncz » Thursday 12 January 2017 11:31

Hi All,

I'm new to Domoticz and my qestion is probably basic, but I wasn't able to find an asnwer anywhere.

My goal: setup a door sensor as a single switch - type "contact"
Hardware: kerui door sensor connected through RFLink Gateway. It sends both "open" and "close" signals (https://www.aliexpress.com/item/6pcs-lot-New-433mhz-While-Wireless-Home-Alarm-Window-Door-Sensor-to-Detect-Open-Door/32463726744.html)
What I did so far: The sensor is detected as two devices: type - Light/Switch, subtype: Eurodomest, Data: Open and Closed respectively
Problem: When I click "add light/switch device", I create two separate switches - one that records door opening and one recording door closing. I'd like to have a single switch, that would show Open or Closed.

Thanks in advance for any ideas.

cheers
Lech

ljoncz
Posts: 3
Joined: Thursday 12 January 2017 11:15
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Door Sensor as a single switch

Postby ljoncz » Friday 13 January 2017 23:56

I figured it out - here is my solution in case it helps anyone.

step 1: add two devices as switches ("Door Open", "Door Closed")
step 2: change the type of the switch to "Push On Button" and "Push Off Button" respectively
step 3: add a virtual sensor ("Front Door") and add it as a switch
step 4: create a device script:

Code: Select all

commandArray = {}
if
   devicechanged['Door Open'] == 'On'
then
   commandArray['Front Door'] = 'On'     
end
if
   devicechanged['Door Closed'] == 'Off'
then
   commandArray['Front Door'] = 'Off'
end
return commandArray


If there is a simpler way - I'd appreciate if you post the solution here.

Cheers

sion
Posts: 45
Joined: Friday 08 January 2016 13:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Door Sensor as a single switch

Postby sion » Saturday 14 January 2017 1:48

Could you just put a Json command in the on action of the closed switch, that would turn off the switch that was turned on by the open contact.

http:// <username:password>@domoticz-ip<:port>/json.htm?type=command&param=switchlight&idx=<switch id>&switchcmd=Off
running domoticz 3.4834 on rpi2, with
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.

Next: harmony hub.

Swifty
Posts: 8
Joined: Saturday 31 December 2016 22:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Door Sensor as a single switch

Postby Swifty » Saturday 14 January 2017 1:53

Hmm I just added the open device then added the close device as a sub device of open, finally edit the master device to set it as contact type.

It seems to register open/closed fine - but is this not the best way to do it then?

sion
Posts: 45
Joined: Friday 08 January 2016 13:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Door Sensor as a single switch

Postby sion » Saturday 14 January 2017 1:59

Swifty wrote:Hmm I just added the open device then added the close device as a sub device of open, finally edit the master device to set it as contact type.

It seems to register open/closed fine - but is this not the best way to do it then?


This seems the simplest way :)
Didn't think about sub device.
running domoticz 3.4834 on rpi2, with
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.

Next: harmony hub.


Return to “Lights and Switches”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest