I am running Domoticz in more than one location, and would like to collect the uptime on a central server.
Is it possible to take the uptime value in LUA, in order to send it through MQTT?
Domoticz uptime
Moderators: leecollings, remb0
-
manjh
- Posts: 859
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Domoticz uptime
Hans
-
Geitje
- Posts: 170
- Joined: Monday 22 January 2018 21:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Domoticz uptime
Great
. Would be even greater if you briefly share where or found the solution, so others searching the forum can find it more easily. [And consider editing the title].
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Zwave, Zigate, RFlink etc.
-
manjh
- Posts: 859
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Re: Domoticz uptime
I don't remember exactly where I found it, but a simple google search brought me there.
Here's the code I am using now:
As for editing the title of this thread: why? It covers exactly what I was looking for!
Here's the code I am using now:
Code: Select all
return {
on = { timer = {"every 5 minutes"}},
execute = function(dz)
local uptimeTextDevice = dz.devices("Utrecht Domoticz uptime")
local minutes = dz.startTime.minutesAgo%60
local days = dz.startTime.daysAgo
local hours = dz.startTime.hoursAgo%24
if days == 1 then
DagText = " dag"
else
DagText = " dagen"
end
uptimeTextDevice.updateText(days ..DagText..", " .. hours .. " uur en " .. minutes .. " minuten" )
end
}
Hans
-
manjh
- Posts: 859
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Re: Domoticz uptime
Since I was getting the code for display here, I thought it might be good to add Raspberry Pi uptime as well.
Here's the modified code:
Here's the modified code:
Code: Select all
return {
on = { timer = {"every 5 minutes"}},
execute = function(dz)
-- set names of text devices
local DomoticzUptimeTextDevice = dz.devices("Utrecht Domoticz uptime")
local RaspberryUptimeTextDevice = dz.devices("Utrecht R-Pi uptime")
-- prepare and store Domoticz uptime
local minutes = dz.startTime.minutesAgo%60
local days = dz.startTime.daysAgo
local hours = dz.startTime.hoursAgo%24
if days == 1 then
DagText = " dag"
else
DagText = " dagen"
end
DomoticzUptimeTextDevice.updateText(days ..DagText..", " .. hours .. " uur en " .. minutes .. " minuten" )
-- prepare and store R-Pi uptime
local f = assert(io.popen('uptime', 'r'))
local uptime = assert(f:read('*a'))
f:close()
RaspberryUptimeTextDevice.updateText(uptime)
end
}
Hans
-
Geitje
- Posts: 170
- Joined: Monday 22 January 2018 21:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Domoticz uptime
Thanks, nice to have the code. About the topic title: I ment something like adding "solved" to title. But know I'm whining...
. And it's not needed...
manjh wrote: Monday 27 April 2020 14:31 As for editing the title of this thread: why? It covers exactly what I was looking for!
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Zwave, Zigate, RFlink etc.
Who is online
Users browsing this forum: No registered users and 1 guest