For another layer of difficulty i want to add is, when i press a button i can cycle through other lines of text on my lcd2004 display.
With the help from openAI i got a script in dzVents that in theory does wat i want but when it runs it gives an error.
Resolving this problem is a bridge to far for the artificial intelligence, essencialy it gave up:
I have asked openAI to try and use a global counter, persistent data, user variables but everytime it failed.If none of these steps solve the issue, you might consider posting the log files and more details about your setup in a domoticz forum. They will be able to help you troubleshoot the issue more effectively.
One of the problems i found that Domoticz uses dzVents 3.1.8, openAI uses version version 3.8xxx, from than on i asked openAI to use version 3.1.8 to make the scripts.
OpenAI tried at some point to make something but it could'nt get it to work in dzVents but remade it into LUA, id prefer dzVents for getting the values from some devices.
So here we are, is there a way to get a (global) counter that counts from 1 to 3 and than resets to 1 so a buttonpress is sending different texts the display everytime..(There are 3 different texts in this script.)
OpenAI last script gives the following error:
Error: EventSystem: in Script #2: [string "..."]:13: attempt to index a nil value (global 'domoticz')
Code: Select all
-- Create a global variable to store the counter
global = global or {}
global.counter = global.counter or 0
local value1 = 123
local value2 = 456
local value3 = 789
-- Get the switch device by name
local switch = domoticz.devices("Schakelaar op display2004")
-- Check if the switch is turned off
if switch.state == "Off" then
-- Increment the counter
if global.counter < 3 then
global.counter = global.counter + 1
else
global.counter = 1
end
-- Check the value of the counter
if global.counter == 1 then
-- Log the message and open the URL
-- domoticz.log('Buffervat bovenin: ' .. value3, domoticz.LOG_INFO)
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,1,1,Electrakosten%FE' .. value1 ..'EUR')
domoticz.log('Waterkosten vandaag: ' .. value2, domoticz.LOG_INFO)
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,2,1,%FEkosten%FEwater%FE' .. value2 ..'EUR')
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,3,1,%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE')
elseif global.counter == 2 then
-- Log the message and open the URL
--domoticz.log('Buffervat bovenin: ' .. value3, domoticz.LOG_INFO)
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,1,1,%FE%FE%FE%FEbuffervat%FE' .. value3 ..'%DFC')
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,2,1,%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE')
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,3,1,%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE')
elseif global.counter == 3 then
-- Log the message and open the URL
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,1,1,%FE%FE%FE%FE%FE%FE%FE%FETEST%FE%FE%FE%FE%FE%FE%FE%FE')
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,2,1,%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE')
domoticz.openURL('http://192.168.178.220/control?cmd=lcd,3,1,%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE%FE')
end
-- Log the counter value
domoticz.log("Counter value: " .. global.counter, domoticz.LOG_INFO)
end