Page 1 of 1

Create DzVents scripts with ChatGTP

Posted: Thursday 12 January 2023 10:15
by Emax
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:
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."

Re: Create DzVents scripts with OpenChat AI

Posted: Thursday 12 January 2023 10:29
by jvdz
I would trigger the script more often than every hour as it could be that the lights are one for 1:59 before you get the notification. make that something like every 5 minutes.

Re: Create DzVents scripts with OpenChat AI

Posted: Thursday 12 January 2023 11:26
by Emax
Sure but this was just a quick example to show that you can let AI write your DzVents scripts for you.

It is not perfect yet but it could be a great help to get you started with a DzVents script.

Re: Create DzVents scripts with OpenChat AI

Posted: Thursday 12 January 2023 14:10
by willemd
I think it is quite impressive. The logic is perfect and the use of the lastupdate.minutesago is smart. Indeed need to run it more often but seems very useful to get started. On to more complex situations ......