I planning to write a script with multiple devices (i.e switches) in the selection field.
A question. How to detect, using if logic, which one triggers the script?
Which device triggers the scrip? [Solved]
Moderator: leecollings
Re: Which device triggers the scrip?
Use dzVents and you can find the trigger devices by name.
The first 2 post explain more.
The first 2 post explain more.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Which device triggers the scrip? [Solved]
If you insist on using if logic (if logic is not needed to identify which device triggered the script) you can use something like below.
Code: Select all
return
{
on =
{
devices =
{
'deviceA',
'deviceB',
},
},
logging =
{
level = domoticz.LOG_INFO,
marker = 'trigger identifyer',
},
execute = function(dz, item)
local deviceA = dz.devices('deviceA')
local deviceB = dz.devices('deviceB')
if item == deviceA then
dz.log('script was triggered by deviceA',dz.LOG_INFO)
elseif item == deviceB then
dz.log('script was triggered by deviceB',dz.LOG_INFO)
end
end
}
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