Can you share that complete part of the log where you see the the door opening and closing ?dutchronnie wrote: ↑Sunday 05 January 2020 19:03 I see in the log door goes open and door is closed.
Doorswitch to turn on and off a light Topic is solved
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Doorswitch to turn on and off a light
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 16
- Joined: Thursday 28 November 2019 0:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: Doorswitch to turn on and off a light
Hi,
I have some of the same door/window sensors. They send a 'On' command for both the open and close state but with a different EV1527 code.
Maybe try to change:
with
Jimmy
I have some of the same door/window sensors. They send a 'On' command for both the open and close state but with a different EV1527 code.
Maybe try to change:
Code: Select all
if door == open then
...
elseif door == closed then
...
Code: Select all
if door.name == open.name then
...
elseif door.name == closed.name then
...

Jimmy
RPI4, Philips Hue, Tradfri, Sonoff, MQTT, Zigbee2Mqtt, RFXCom 433, Octoprint,...
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Doorswitch to turn on and off a light
Always worth a try but in this case that should not make a difference. In door == open, I compare the device object to the triggering object. Here it will have the same result as checking the names (a string). Name is just one attribute of the object so in theory you can get a false positive when checking only this attribute (different objects with equal name attributes)James83 wrote: ↑Sunday 05 January 2020 20:11 Maybe try to change:withCode: Select all
if door == open then ... elseif door == closed then ...
Code: Select all
if door.name == open.name then ... elseif door.name == closed.name then ...
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 46
- Joined: Thursday 15 August 2013 22:01
- Target OS: -
- Domoticz version:
- Contact:
Re: Doorswitch to turn on and off a light


It is working now.
I changed some names, so i post the script:
Code: Select all
return {
active = true,
on = {
devices = {
['deur open'] = { 'at nighttime' },
['deur close'] = { 'at nighttime' },
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz, door)
_G.logMarker = _G.moduleLabel
local light = dz.devices('deur')
open = dz.devices('deur open')
closed = dz.devices('deur close')
dz.log('state of ' .. door.name .. ': ' .. door.state .. ' => ' .. (door.active and ' active' or 'not active') )
if door.name == open.name then
light.switchOn()
elseif door.name == closed.name then
light.switchOff().afterSec(10)
end
end
}
Thanks a lot to you all.2020-01-05 22:25:28.191 Status: dzVents: Info: Handling events for: "deur open", value: "On"
2020-01-05 22:25:28.191 Status: dzVents: Info: ------ Start internal script: Deur open en dicht: Device: "deur open (RFLink Gateway)", Index: 273
2020-01-05 22:25:28.196 Status: dzVents: Debug: Deur open en dicht: Processing device-adapter for deur: Switch device adapter
2020-01-05 22:25:28.198 Status: dzVents: Debug: Deur open en dicht: Processing device-adapter for deur close: Switch device adapter
2020-01-05 22:25:28.198 Status: dzVents: Info: Deur open en dicht: state of deur open: On => active
2020-01-05 22:25:28.198 Status: dzVents: Debug: Deur open en dicht: Constructed timed-command: On
2020-01-05 22:25:28.198 Status: dzVents: Info: Deur open en dicht: ------ Finished Deur open en dicht
2020-01-05 22:25:28.200 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-01-05 22:25:30.707 (RFLink Gateway) Light/Switch (deur close)
2020-01-05 22:25:30.911 Status: dzVents: Info: Handling events for: "deur close", value: "On"
2020-01-05 22:25:30.911 Status: dzVents: Info: ------ Start internal script: Deur open en dicht: Device: "deur close (RFLink Gateway)", Index: 274
2020-01-05 22:25:30.913 Status: dzVents: Debug: Deur open en dicht: Processing device-adapter for deur: Switch device adapter
2020-01-05 22:25:30.915 Status: dzVents: Debug: Deur open en dicht: Processing device-adapter for deur open: Switch device adapter
2020-01-05 22:25:30.915 Status: dzVents: Info: Deur open en dicht: state of deur close: On => active
2020-01-05 22:25:30.916 Status: dzVents: Debug: Deur open en dicht: Constructed timed-command: Off
2020-01-05 22:25:30.916 Status: dzVents: Debug: Deur open en dicht: Constructed timed-command: Off AFTER 10 SECONDS
2020-01-05 22:25:30.916 Status: dzVents: Info: Deur open en dicht: ------ Finished Deur open en dicht
2020-01-05 22:25:30.918 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
I can now build futher with my home automation.
-
- Posts: 16
- Joined: Thursday 28 November 2019 0:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Belgium
- Contact:
Re: Doorswitch to turn on and off a light
Glad it's solved
Meanwhile did a quick test with and without the .name attribute.
Both output true if so
so, issue must have been in the name of the devices.
Jimmy

Meanwhile did a quick test with and without the .name attribute.
Both output true if so
so, issue must have been in the name of the devices.
Jimmy
RPI4, Philips Hue, Tradfri, Sonoff, MQTT, Zigbee2Mqtt, RFXCom 433, Octoprint,...
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Doorswitch to turn on and off a light
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest