door sensor and sonoff bridge

Moderator: leecollings

Post Reply
henrybcn
Posts: 31
Joined: Wednesday 31 August 2016 11:17
Target OS: OS X
Domoticz version:
Contact:

door sensor and sonoff bridge

Post by henrybcn »

Hi All,
I got several door sensors and a sonoff bridge.
I uploaded tasmota to the bridge and it is working fine. I can connect to its IP and also see it in domoticz following the instructions from Jelle Peters on youtube
https://www.youtube.com/watch?v=Y4UlFjPT5do.
I can see the door sensor in both logs (domoticz and bridge), but I am really struggling to assign a switch were I can see if the door is open or closed.
After reading over the last week, seems this can be done with node-red, but also with scripts directly in domoticz. My preference would be to do not install anything else. Seems the scripts are fairly straight forward and I will not need anything else, but simply reading if the door is open/closed.
I think I read all the posts, but really did not find a clear answer.
I followed what is in the post https://www.domoticz.com/forum/viewtopic.php?t=25748, but I am stuck on the switch/script.
Here are my readings from the domoticz log when I open/close the door switch:

2020-06-09 21:06:50.116 MQTT: Topic: domoticz/in, Message: {"idx":15,"nvalue":0,"svalue":"9759754","Battery":100,"RSSI":7}
2020-06-09 21:07:08.181 MQTT: Topic: domoticz/in, Message: {"idx":15,"nvalue":0,"svalue":"9759758","Battery":100,"RSSI":7}

I also tried to copy one of the scripts and edit it:

return {
on = { devices = { "sonoff bridge" } },

execute = function(dz, item)

if item.rawData[1] == "9759758" then
item.switchOn().checkFirst().silent()
else
item.switchOff().checkFirst().silent()
end
end
}

but my switch does not update the status....

I guess I am doing something really dumb... Any thougths/help?
Tks so much!
Henry
henrybcn
Posts: 31
Joined: Wednesday 31 August 2016 11:17
Target OS: OS X
Domoticz version:
Contact:

Re: door sensor and sonoff bridge

Post by henrybcn »

I just sorted out. Posting in case helps anyone.... Was fairly simple.
Created a dummy sensor (idx 17) in domoticz
On the Sonoff Bridge at "domoticz parameters" I assigned the idx17 on Count/PM1
And the script below in domoticz:

return {
active = true,
on = { devices = { 17 } },

execute = function(dz, item)

if item.rawData[1] == "9759754" then
item.switchOn().checkFirst().silent()
else
item.switchOff().checkFirst().silent()
end
end
}

I am not planning to have another door sensor, but I am curious to know how to add a 2nd one using another idx...
If anyone has the answer, I would be curious ;)
pigulka
Posts: 1
Joined: Friday 12 June 2020 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: door sensor and sonoff bridge

Post by pigulka »

Hi henrybcn.
Open the calculator in the application. As a HEX and replace with DEC HEX 9759758 ,9759758

Create virtual dummy as much as you need
door1 .idx 1.. (drzwi_balkon)
door2..idx 2...
type door contact (drzwi_balkon)

Run Blocky.
Bez tytułu.png
Bez tytułu.png (140.25 KiB) Viewed 1277 times
my log {"Time":"2020-06-12T13:53:43","RfReceived":{"Sync":13010,"Low":450,"High":1260,"Data":"0824F9","RfKey":"None"}}
13:53:43 MQT: domoticz/in = {"idx":103,"nvalue":0,"svalue":"533753","Battery":100,"RSSI":10}
13:53:46 MQT: tele/tasmota_C0CD6E/RESULT = {"Time":"2020-06-12T13:53:46","RfReceived":{"Sync":12790,"Low":430,"High":1250,"Data":"830616","RfKey":"None"}}
13:53:46 MQT: domoticz/in = {"idx":103,"nvalue":0,"svalue":"8586774","Battery":100,"RSSI":10}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest