Create DzVents scripts with ChatGTP
Posted: Thursday 12 January 2023 10:15
Really interesting, maybe you already heard about this new AI ChatGPT (https://chat.openai.com) but I found that it is also able to create DzVents scripts based on your description, here just a very simple example I just let it create:
My question: "Write a DzVents scripts that checks if device Bathroom is on for for more then 1 hour and send an email alert to [email protected] saying that the Bathroom lights are on for a long time "
Answer:
My question: "Write a DzVents scripts that checks if device Bathroom is on for for more then 1 hour and send an email alert to [email protected] saying that the Bathroom lights are on for a long time "
Answer:
return {
on = {
timer = {
'every 1 hour'
}
},
execute = function(domoticz, device)
if (device.name == 'Bathroom' and device.state == 'On') then
if (device.lastUpdate.minutesAgo > 60) then
domoticz.email('[email protected]', 'Bathroom lights on for a long time', 'The Bathroom lights have been on for more than an hour.')
end
end
end
}
This script uses the on-timer trigger to execute a function every hour. Inside the function, it checks if the device named "Bathroom" is on and it has been on for more than 60 minutes. If that is the case, it sends an email to [email protected] with the subject "Bathroom lights on for a long time" and the message "The Bathroom lights have been on for more than an hour."