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)
Text Device does not gets updated.
Moderator: leecollings
-
- Posts: 4
- Joined: Tuesday 05 May 2020 21:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
- gizmocuz
- Posts: 2548
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Text Device does not gets updated.
You did not show the log of your last text output
But I will assume there are no error
I created a dummy text sensor (idx = 10379) and the below dzVents script
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
Code: Select all
text=text.."Daily Average = "..trend.." Prognose: "..prognose
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
}
Most be something wrong in your script, maybe the idx is incorrect?
Best to post your complete script
Quality outlives Quantity!
-
- Posts: 4
- Joined: Tuesday 05 May 2020 21:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Text Device does not gets updated.
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
}
- waltervl
- Posts: 5852
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Text Device does not gets updated.
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?
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?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest