Page 1 of 1
How to monitor my devices (last update, value,...)
Posted: Sunday 22 February 2015 15:35
by boubil
I would like to be informed when a device is no logger updated by domotics.
For example if a temperature device has not been updated for the past 4 hours I would like it to display a red title on my home page or in the temperature tab.
I have noticed that one of my fibaro plug which is not plugged is displayng a red title in the utility tab for energy monitoring.
I would like to have the same for all devices.
How can I do this ?
Thank a lot for your help
Re: How to monitor my devices (last update, value,...)
Posted: Sunday 22 February 2015 15:41
by Siewert308SW
I only can mention you that the widgets are red colored when a device isn't seen for a long period.
Domoticz lost the connection with a 433mhz temp device in my fridge.
And after two days i noticed the widget top bar was colored red and saw it wasn't updated for two days.
As for a notification you could use a lua script to send you a notification if a device is offline for a longer period of time.
Re: How to monitor my devices (last update, value,...)
Posted: Monday 27 June 2016 0:44
by Flopp
Re: How to monitor my devices (last update, value,...)
Posted: Tuesday 01 November 2016 7:45
by anasazi
Hi,
I have been looking at this code but I'm little confused...
In the if statement it will check if (uservariables[cmd] == 0) but where does this script create these variables?
Do I have to add them in Domoticz --> Setup --> User variables?
As of of now the script will never go through the if statements because these variables doesn't seem to exists...
Code: Select all
commandArray = {}
local function update(cmd)
vari = "Variable:" .. cmd --add Variable: before device
t1 = os.time() --get date/time right now in seconds
t3 = os.date("%Y-%m-%d %H:%M:%S") --get date/time right now in normal format
s = otherdevices_lastupdate[cmd] --read last date/time for device
--print(cmd)
--print(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2)) --compare right now with device
if (difference > 2400) and (uservariables[cmd] == 0) then --if device date/time is more than 30 minutes
commandArray['SendEmail']=''..cmd..' äldre än 40 min#'..s..' är senaste tid#[email protected]' --send mail
commandArray[vari] = "1" --set variable to 1
elseif (difference < 2400) and (uservariables[cmd] == 1) then --if device date/time is less than 30 minutes
commandArray[vari] = "0"
commandArray['SendEmail']=''..cmd..' ok igen#'..s..' är senaste tid#[email protected]'
end
end
update ('OutsideTemp') --device name can be temperature or voltage
update ('InsideTemp)
return commandArray
How to monitor my devices (last update, value,...)
Posted: Tuesday 01 November 2016 8:41
by Flopp
You have not copied the whole the code.
At the bottom there is Update ('xxxxx').
Update is calling a function called Update and the name between brackets is you device name, which will be used in the function Update and the variable name inside this Function is named cmd.
You need to use whole code and rename the devices so it fits your setup
Re: How to monitor my devices (last update, value,...)
Posted: Tuesday 01 November 2016 9:08
by anasazi
Hi,
In the last part in the code I do have the update code.
In my example it's
Code: Select all
update ('OutsideTemp') --device name can be temperature or voltage
update ('InsideTemp)
But don't I have to set either "0" or "1" to these variable somehow when the script starts (uservariables[cmd])?
Because if I don't it will none of the if statements will work...
if (difference > 2400) and (uservariables[cmd] == 0)
elseif (difference < 2400) and (uservariables[cmd] == 1)
Re: How to monitor my devices (last update, value,...)
Posted: Tuesday 01 November 2016 9:21
by Flopp
Sorry, you are correct. I have almost forgot how it worked.
You need to create a User Variable with the same name as your device/s you are using in this script.
Re: How to monitor my devices (last update, value,...)
Posted: Tuesday 01 November 2016 10:53
by anasazi
Thank you!
Added a User Variable with same name as my temp sensor and it started working immediately

Re: How to monitor my devices (last update, value,...)
Posted: Tuesday 01 November 2016 16:23
by Flopp
anasazi wrote:Thank you!
Added a User Variable with same name as my temp sensor and it started working immediately

Great