Maybe I misunderstand your question but the script I posted already does this. It will only send a message when atHome is not true.Fredom wrote: Wednesday 18 November 2020 20:37 The notifications always come when a door opens, even when the phone is at home.
Help needed with script [Solved]
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Help needed with script
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
-
Fredom
- Posts: 160
- Joined: Saturday 19 September 2020 21:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2025.1
- Location: Krimpen aan den IJssel
- Contact:
Re: Help needed with script
waaren wrote: Wednesday 18 November 2020 21:48Maybe I misunderstand your question but the script I posted already does this. It will only send a message when atHome is not true.Fredom wrote: Wednesday 18 November 2020 20:37 The notifications always come when a door opens, even when the phone is at home.
Hi Waaren,
Thanks for your quick response
I am now using your latest script I have only changed the switch names.
The script works perfectly, only the notifications also come when Thuis is on.
This shouldn't be.
I have also tried a few things myself, but I can't figure it out (yet).
Code: Select all
--(dzVents)--
--Door open and 'Thuis' is On then no telegram
--Door open and 'Thuis' is Off then send telegram with name of the door and door is open
--Thuis is Dummy switch that is on when smartphone is at home
--WCD On if 'Thuis'is Off and door state is Alarm, and switch Off when door state is Normal
--Door is an Kerui D026
--Telegram is activated
local doors =
{
'Voordeur',
'Garagedeur',
'Schuifdeur',
'Testdeur', --for testing
}
local allDevices = doors -- copy the doors table to table allDevices
table.insert(allDevices, 'Thuis') -- this will add this deviceName to the table allDevices
return
{
on =
{
devices = allDevices,
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'deur',
},
execute = function(dz)
local delay = 300 -- set to amount of seconds the light should stay on
local allDoorsClosed = true
local Thuis = dz.devices('Thuis') --atHome
local wcd = dz.devices('WCD') --Light switch
local atHome = Thuis.active
dz.log('state of WCD is ' .. wcd.state , dz.LOG_DEBUG)
dz.log('state of Thuis is ' .. dz.devices('Thuis').state .. '; atHome is ' .. tostring(atHome), dz.LOG_DEBUG)
if atHome then
wcd.switchOff().checkFirst() -- phone is atHome so we can switchOff the wcd if it's on.
else
for _, doorName in ipairs(doors) do
local door = dz.devices(doorName)
dz.log('state of ' .. doorName .. ' is ' .. door.state .. ' (' .. ( ( door.active and 'active' ) or 'not active' ) .. ')', dz.LOG_DEBUG)
if door.state == 'Open' or door.state == 'Alarm' then -- a door is open
allDoorsClosed = false
wcd.cancelQueuedCommands()
wcd.switchOn()
wcd.switchOff().afterSec(delay)
dz.log('wcd activated for ' .. delay .. ' seconds because ' .. doorName .. ' is open.' , dz.LOG_DEBUG)
dz.notify('Devices', 'Device ' .. doorName .. ' staat open ')
break -- no need to look at the other doors if one is open.
end
end
if allDoorsClosed then
wcd.switchOff().checkFirst() -- All doors are closed so we can switchOff the wcd when it is on
end
end
end
}
Code: Select all
2020-11-18 20:28:45.951 Status: Notification: Testdeur geopend
2020-11-18 20:28:46.099 Status: dzVents: Info: Handling events for: "Testdeur", value: "Alarm"
2020-11-18 20:28:46.099 Status: dzVents: Info: deur: ------ Start internal script: Deur open melding telegram: Device: "Testdeur (RFX)", Index: 223
2020-11-18 20:28:46.100 Status: dzVents: Debug: deur: Processing device-adapter for Thuis: Switch device adapter
2020-11-18 20:28:46.102 Status: dzVents: Debug: deur: Processing device-adapter for WCD: Switch device adapter
2020-11-18 20:28:46.102 Status: dzVents: Debug: deur: state of WCD is Off
2020-11-18 20:28:46.102 Status: dzVents: Debug: deur: state of Thuis is On; atHome is true
2020-11-18 20:28:46.102 Status: dzVents: Debug: deur: Constructed timed-command: Off
2020-11-18 20:28:46.102 Status: dzVents: Info: deur: ------ Finished Deur open melding telegram
2020-11-18 20:28:55.392 Status: dzVents: Info: Handling events for: "Testdeur", value: "Normal"
2020-11-18 20:28:55.392 Status: dzVents: Info: deur: ------ Start internal script: Deur open melding telegram: Device: "Testdeur (RFX)", Index: 223
2020-11-18 20:28:55.395 Status: dzVents: Debug: deur: Processing device-adapter for Thuis: Switch device adapter
2020-11-18 20:28:55.397 Status: dzVents: Debug: deur: Processing device-adapter for WCD: Switch device adapter
2020-11-18 20:28:55.397 Status: dzVents: Debug: deur: state of WCD is Off
2020-11-18 20:28:55.397 Status: dzVents: Debug: deur: state of Thuis is On; atHome is true
2020-11-18 20:28:55.397 Status: dzVents: Debug: deur: Constructed timed-command: Off
2020-11-18 20:28:55.398 Status: dzVents: Info: deur: ------ Finished Deur open melding telegramYours sincerely,
Fred
Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fred
Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Help needed with script
I really don't see it. Which line do you think shows that a message is send?Fredom wrote: Wednesday 18 November 2020 22:12 In below text you can see dat it is sending an message when atHome is active
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
-
Fredom
- Posts: 160
- Joined: Saturday 19 September 2020 21:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2025.1
- Location: Krimpen aan den IJssel
- Contact:
Re: Help needed with script
Hi Waaren,
I think I found the problem.
The notification comes from domoticz and the switch.
I changed the script's message slightly and I don't see it in Telegram.
I have to remove the notifications from the switches I think
Is this correct?
It was the name of the script that I mistook for a message (sorry).
Yours sincerely,
Fred
Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fred
Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Help needed with script
If you only want notifications from the script then you should indeed remove them from the devices.Fredom wrote: Wednesday 18 November 2020 22:37 I have to remove the notifications from the switches I think
Is this correct?
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
-
Fredom
- Posts: 160
- Joined: Saturday 19 September 2020 21:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2025.1
- Location: Krimpen aan den IJssel
- Contact:
Re: Help needed with script [Solved]
Hi Waaren,
The text I get from the script in Telegram is
"device Voordeur is open"
I have now removed all notifications from the devices and now (as you already knew) it
works as I wish.
Learned something new.
Thank you for your effort
Gr
Fred
Yours sincerely,
Fred
Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fred
Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Who is online
Users browsing this forum: No registered users and 1 guest