Who can get this script working for me?
The intention is that if a telephone comes into the house and 'Thuis' is Off,
a notification will be sent to Telegram with the name of the telephone.
And when 'Thuis' is On, no message goes to telegram.
Code: Select all
local phone =
{
'Mobiel Mariska',
'Mobiel Barney',
'Mobiel Nils',
'Mobiel Test'
}
local allDevices = phone -- copy the phones table to table allDevices
table.insert(allDevices, 'Thuis') -- this will add this deviceName to the table allDevices
return
{
active = true,
on =
{
devices = allDevices,
},
execute = function(dz, devices)
local schakelaar = dz.devices('Thuis')
local atHome = Thuis.active
if schakelaar.active then
return
else
for _, phoneName in ipairs(phone) do
local phone = dz.devices(phoneName)
if not(schakelaar.active) then
dz.notify('Devices', 'Device ' .. phoneName .. ' komt binnen ')
end
end
end
}
Fredom