Hi,
how can I get the time of the last change of a temperature sensor? Not the last update because this is every time receive datas from sensor, but not the last change of value.
Temperature last change of value
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Temperature last change of value
The only way to do that in domoticz is to store last changed value somewhere. You could store it in a domoticz variable or in a virtual sensor or in dzVents persistent data.
a dzVents solution for this can be like below script example.
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
return
{
on =
{
devices =
{
'Internal Temperature', -- change to name of your sensor
},
},
data =
{
temperature =
{
history = true,
maxItems = 1,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when working OK
},
execute = function(dz, item)
local currentTemperature = tostring(dz.utils.round(item.temperature,1))
if dz.data.temperature.size > 0 then
local lastTemperature = dz.data.temperature.getLatest().data
local lastTime = dz.data.temperature.getLatest().time
dz.log('Temperature of Sensor ' .. item.name .. ' was ' .. lastTemperature .. ' at ' .. lastTime.rawDate .. ' ' .. lastTime.rawTime , dz.LOG_DEBUG)
dz.log('Temperature of Sensor ' .. item.name .. ' is now ' .. currentTemperature , dz.LOG_DEBUG)
if lastTemperature ~= currentTemperature then
dz.data.temperature.add(currentTemperature)
end
else
dz.data.temperature.add(currentTemperature)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 21
- Joined: Monday 05 October 2015 9:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Temperature last change of value
Thank you,
my script in use is written with lua and not the shortest. I
I will find a way to integrate your idea.
my script in use is written with lua and not the shortest. I
I will find a way to integrate your idea.
Who is online
Users browsing this forum: No registered users and 0 guests