Read CPU and pass to MySensors LCD
Posted: Sunday 13 January 2019 20:07
Hello,
I'm trying to do this in dzVents:
But the log file returns:
Attached image of what I'm trying to do:
I'm trying to do this in dzVents:
Code: Select all
--[[
Domoticz dzVents script for Machinon LCD
Displays the device's Ethernet IP (either DHCP or static) on Machinon LCD using a shell script to get the local IP (or "unknown" if disconnected)
Also shows static info for Kit
]]
return {
-- trigger
-- can be a combination:
on = {
-- timer riggers
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
-- 1 minute is shortest interval and also the timer granularity???
'every 1 minutes'
}
},
-- custom logging level for this script
logging = {
level = domoticz.LOG_DEBUG,
marker = "show-ip script"
},
-- actual event code
-- the second parameter is depending on the trigger
-- when it is a device change, the second parameter is the device object
-- similar for variables, scenes and groups and httpResponses
-- inspect the type like: triggeredItem.isDevice
execute = function(domoticz)
domoticz.log('Running show-ip script...', domoticz.LOG_INFO)
local cmd = "/home/pi/domoticz/scripts/machinon-tools/get-ip.sh"
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
-- strip out any /r/n etc
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', '')
local CPUtemp = (domoticz.devices('CPU temp').temperature)
local CPUusage = (domoticz.devices('CPU_Usage').level)
domoticz.log('Got IP = "' .. s .. '"', domoticz.LOG_INFO)
domoticz.log('CPU Temp = "' .. CPUtemp .. '"', domoticz.LOG_INFO)
domoticz.log('CPU % = "' .. CPUusage .. '"', domoticz.LOG_INFO)
domoticz.devices('LCD Line 3').updateText('IP = ' .. s)
domoticz.devices('LCD Line 4').updateText('CPU = ' .. CPUtemp .. '°C')
domoticz.devices('LCD Line 5').updateText('CPU = ' .. s .. '"%"')
-- also update static info in case it gets corrupted/overwriten
--domoticz.devices('LCD Backlight').switchOn()
end
}
How do I read the CPU %?2019-01-13 19:03:00.667 Status: dzVents: Info: show-ip script: Got IP = "172.16.1.250"
2019-01-13 19:03:00.667 Status: dzVents: Info: show-ip script: CPU Temp = "50.5"
2019-01-13 19:03:00.667 Status: dzVents: Info: show-ip script: CPU % = "nil"
Attached image of what I'm trying to do: