Create DzVents scripts with ChatGTP

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Emax
Posts: 11
Joined: Wednesday 23 August 2017 10:39
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Create DzVents scripts with ChatGTP

Post 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."
Last edited by Emax on Monday 30 January 2023 18:19, edited 1 time in total.
User avatar
jvdz
Posts: 2351
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Create DzVents scripts with OpenChat AI

Post 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.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Emax
Posts: 11
Joined: Wednesday 23 August 2017 10:39
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Create DzVents scripts with OpenChat AI

Post 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.
willemd
Posts: 662
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Create DzVents scripts with OpenChat AI

Post 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 ......
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest