Page 1 of 1
Text Device does not gets updated.
Posted: Friday 13 June 2025 9:21
by mroerigdalgaard
After last update my TXT alert device i broken.
I can see in the log that it gets updates. But the Text value of the device is empty and nothing is shown in the GUI....
The Text is shown in my LogFile by the DoLogE function....
Som ideas?
The log:
2025-06-13 09:03:38 Alertlevel = >none< Daily Alarm = Off - Alerts: 0 Daily Average = 39.667 Prognose: 251.833 dzVents//home/pi/domoticz/dzVents/runtime/dzVents.lua
My code:
text="Alertlevel = "..txtLevel.." Daily Alarm = "..txtDay.." - Alerts: "..daycount.."<br>"
text=text.."Daily Average = "..trend.." Prognose: "..prognose
[...]
DoLogE("Text: ["..text.."]")
domoticz.devices(122).updateText(text)
Re: Text Device does not gets updated.
Posted: Friday 13 June 2025 9:56
by gizmocuz
You did not show the log of your last text output
Code: Select all
text=text.."Daily Average = "..trend.." Prognose: "..prognose
But I will assume there are no error
I created a dummy text sensor (idx = 10379) and the below dzVents script
Code: Select all
return {
on = {
timer = {
'every minute', -- causes the script to be called every minute
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'text test',
},
execute = function(domoticz, timer)
domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO)
local text = 'Does this work correctly?'
domoticz.devices(10379).updateText(text)
end
}
And my text sensor is updated correctly.
Most be something wrong in your script, maybe the idx is incorrect?
Best to post your complete script
Re: Text Device does not gets updated.
Posted: Wednesday 18 June 2025 13:26
by mroerigdalgaard
Code: Select all
return {
on = {
devices = { 123, }
},
logging = {
level = domoticz.LOG_INFO,
marker = 'SetLTELevel',
},
execute = function(domoticz, device)
local function DoLogE(str)
local marker = "SetLTELevel"
local ltime = ""
local logfile = io.open("/home/pi/dzvents.log", "a")
ltime=os.date("%Y-%m-%d %H:%M:%S")
logfile:write(ltime.." ["..tostring(marker).."] [Warning] "..tostring(str).."\n")
print(" ["..tostring(marker).."] [Warning] "..tostring(str))
logfile:close()
end
local function DoLog(str)
local marker = "SetLTELevel"
local ltime = ""
-- local logfile = io.open("/home/pi/dzvents.log", "a")
ltime=os.date("%Y-%m-%d %H:%M:%S")
-- logfile:write(ltime.." ["..tostring(marker).."] [Warning] "..tostring(str).."\n")
print(" ["..tostring(marker).."] [Info] "..tostring(str))
-- logfile:close()
end
if (domoticz.devices(123).state == "On") then
local oldlevel = 0
local forbrug = 0
local dayly = 0
local daylyalarm = 0
local sendnotification = 0
local str = ""
local daycount=0
local txtLevel="<none>"
local txtDay=""
local txtAverage= ""
DoLogE("#############################")
str = domoticz.devices(119).sensorValue
str = string.gsub(str,",",".")
forbrug = math.floor(tonumber(str))
dayly = forbrug - domoticz.variables("LastDay").value
daylyalarm = domoticz.variables("DaylyAlarm").value
daycount=domoticz.variables("DayCount").value
local maxday = domoticz.variables("MaxDay").value
local maxmonth = domoticz.variables("MaxMonth").value
local maxhour = domoticz.variables("MaxHour").value
local prognose = domoticz.variables("Prognose").value
DoLogE("Data Str ["..str.."]")
DoLogE("Data value ["..forbrug.."]")
DoLogE("DaylyUsage ["..dayly.."]")
DoLogE("DaylyAlarm ["..daylyalarm.."]")
oldlevel=oldlevel -1
txtLevel="[none]"
DoLogE("OldlevelStart ["..oldlevel.."]")
DoLogE("TextLevel ["..txtLevel.."]")
DoLogE("MaxHour ["..maxhour.."]")
DoLogE("MaxDay ["..maxday.."]")
DoLogE("MaxMonth ["..maxmonth.."]")
if forbrug >= (maxmonth * 0.250) then
txtLevel="1: 25%"
if oldlevel < 1 then
oldlevel = 1
sendnotification = 1
end
end
if forbrug >= (maxmonth * 0.500) then
txtLevel="2: 50%"
if oldlevel < 2 then
oldlevel = 2
sendnotification = 1
end
end
if forbrug >= (maxmonth * 0.800) then
txtLevel="3: 80%"
if oldlevel < 3 then
oldlevel = 3
sendnotification = 1
end
end
if forbrug >= (maxmonth *0.950) then
txtLevel="4: 95%"
if oldlevel < 4 then
oldlevel = 4
sendnotification = 1
end
end
if prognose < maxday then
txtLevel="5: >Prog<"
if oldlevel < 5 then
oldlevel = 5
sendnotification = 1
end
end
DoLogE("OldLevel New ["..oldlevel.."]")
DoLogE("TextLevel New ["..txtLevel.."]")
DoLogE("Update Sensor ["..sendnotification.."]")
if daylyalarm == 1 then txtDay = "[!!!]" else txtDay = "Off" end
if daycount > 0 then txtAverage = " Days over average: "..daycount end
sendnotification=1
if sendnotification == 1 then
local text = ""
local DoW = tonumber(os.date("%d"))
if DoW > 1 then DoW = DoW - 1 end
local trend = domoticz.utils.numDecimals((forbrug/DoW),1,3)
local cy, cm = tonumber(os.date("%Y")), tonumber(os.date("%m"))
local totaldays = os.date("*t", os.time{year=cy, month=cm+1, day=0}).day
local daysleft = totaldays - tonumber(os.date("%d"))+1
if daysleft < 1 then daysleft = 1 end
-- text = "test"
text="Alertlevel = "..txtLevel.." Daily Alarm = "..txtDay.." - Alerts: "..daycount --.."<br>"
text=text.."Daily Average = "..trend.." Prognose: "..prognose
DoLogE("Days lefts ["..daysleft.." of "..totaldays.." days]")
DoLogE("Prognose ["..prognose.."]")
if oldlevel <= 1 then
DoLogE("SetIcon [Green]")
domoticz.devices(122).setIcon('127')
end
if oldlevel == 2 then
DoLogE("SetIcon [Yellow]")
domoticz.devices(122).setIcon('128')
end
if oldlevel == 3 then
DoLogE("SetIcon [Amber]")
domoticz.devices(122).setIcon('130')
end
if oldlevel == 4 then
DoLogE("SetIcon [Red]")
domoticz.devices(122).setIcon('129')
end
if oldlevel >= 5 then
DoLogE("SetIcon [Pink]")
domoticz.devices(122).setIcon('131')
end
DoLogE("Text: ["..text.."]")
domoticz.devices(122).updateText(text)
end
domoticz.devices(123).switchOff().checkFirst()
DoLogE("Script End - - - - - - - - - - - - - - - - -")
end
end
}
Edit Waltervl: Added code brackets for better readability
Re: Text Device does not gets updated.
Posted: Wednesday 18 June 2025 14:21
by waltervl
There is no mention in the normal Domoticz log (menu Setup-Log) about updating device 122?
Is the devicename of device 122 unique?
Why not use an Domoticz alert device instead of a text device and change the icons? See wiki page
https://wiki.domoticz.com/DzVents:_next ... ert_sensor
Why a separate log function while there is a perfectly working log function in Domoticz?
Re: Text Device does not gets updated.
Posted: Thursday 03 July 2025 9:49
by mroerigdalgaard
Device 122 os uniqe.
The logs shows update:
2025-07-03 09:46:32.156 dzVents: Debug: - OpenURL = {["method"]="GET", ["URL"]="
http://127.0.0.1:8080/json.htm?type=com ... mimage=127"}
2025-07-03 09:46:32.156 dzVents: Debug: - UpdateDevice = {["_trigger"]=true, ["idx"]=122, ["sValue"]="Alertlevel = Off - Daily Alarm = Off - Alerts: 0
2025-07-03 09:46:32.156 Daily Average = 83.000 - Prognose: 167.138", ["nValue"]=0}
2025-07-03 09:46:32.156 dzVents: Debug: - Set-Forbrug = Off
But the text field stayes empty...
Alertdevice has differen kind of icons. This text device use an other set of icons.
I have en external logger as domoticz log disappears after minutes. This is more longterm and debugging.
Re: Text Device does not gets updated.
Posted: Thursday 03 July 2025 12:45
by waltervl
What if you temporarily remove the linebreak in the text?
What if you temporarily remove the icon change in the script?
Re: Text Device does not gets updated.
Posted: Thursday 03 July 2025 17:23
by willemd
First try directly updating the device with a browser. In that way you can eliminate an issue with the device itself.
Use the following command
http://domoticzIP:port/type=command¶m=udevice&idx=IDX&nvalue=0&svalue="yourText"
Of course replace DomoticzIP:port, IDX and yourText with the relevant data.
Re: Text Device does not gets updated.
Posted: Monday 28 July 2025 0:11
by YopYop
Hi, I have the exact same problem but only if I change the icon.
If I do this code, the text is updated
Code: Select all
execute = function(dz, device)
--dz.devices('Tempo J').setIcon(128)
dz.devices('Tempo J').updateText('bleu').silent()
end
But with this one, I get the bug: the text isn't displayed anymore.
Code: Select all
execute = function(dz, device)
dz.devices('Tempo J').setIcon(128)
dz.devices('Tempo J').updateText('bleu').silent()
end
And if I use the api to get info with my browser, the data field is empty.
Edit:
After having tried different things, it appears that changing icon erase the text
If I update the text with dzvents, everyting is ok.
Then if I change the icon by dzvents or by using api, then icon is updated and the text is empty.
URL used:
Code: Select all
http://127.0.0.1:8090/json.htm?type=command¶m=setused&used=true&name=Tempo+J&description=&idx=845&switchtype=0&customimage=128
This is the URL that appears in domoticz log.
Re: Text Device does not gets updated.
Posted: Sunday 07 September 2025 10:32
by mroerigdalgaard
You are right.
The icon change couses the trouble...
Re: Text Device does not gets updated.
Posted: Sunday 07 September 2025 10:38
by mroerigdalgaard
I have reported a bug:
Text device: changing icon erases the text #6383
Re: Text Device does not gets updated.
Posted: Friday 12 September 2025 8:59
by gizmocuz
Probably already solved some time ago in the beta version.
You should try this version before reporting an issue.
Also a mention of the github issue (link) should be included here.
Re: Text Device does not gets updated.
Posted: Friday 12 September 2025 9:22
by waltervl