Access to Vera Plus LED Statuses

Hi

I recall this being done on the earlier Veras, but after searching the forum, I cannot seem to find any reference to it now?

Is there some code you can use to retrieve the status of the LEDs on the top of the Vera Plus ?

This was the post with the VeraLite solution in EventWatcher http://forum.micasaverde.com/index.php/topic,16984.msg177617.html#msg177617

I’ve never bothered to try on and Edge or a Plus. In fact, I removed the code from EventWatcher in the latest version.

Arrr thanks for the mention in the EventWatch code :slight_smile:

-- System info blog -- -- thanks to @parkerc for the idea, and @futzle for the solution, to "watching the LEDs" -- see: http://forum.micasaverde.com/index.php/topic,25217.msg177527.html#msg177527 -- # ls /sys/devices/platform/leds-gpio/leds/veralite:*/brightness -- blue:power/brightness, orange:zwave/brightness, red:error/brightness, yellow:lan/brightness --

And this looks to be the code segments

local function getLED (x) local path = "/sys/devices/platform/leds-gpio/leds/veralite:%s/brightness" local value = tonumber (getSystemFile (path:format (x))) return value or 0 end

[code]local power = getLED “blue:power” – LED status lights
local zwave = getLED “orange:zwave”
local lan = getLED “yellow:lan” – it’s actually green
local error = getLED “red:error”
info.VeraLiteLEDS = {val = error + 2*(lan + 2*(zwave + 2*power)) / 255, class = ‘system’} – encode into one variable

[/code]

[code] local LED = systemInfo.VeraLiteLEDS.val
set (“AppMemoryUsed”, AppMemoryUsed)
set (“MemAvail”, mem)
set (“MemFree”, free)
set (“CpuLoad05”, cpu)
set (“VeraLiteLEDS”, LED)
set (“IconSet”, LED % 8) – only use lower three bits of status (ie. ignore powerlight)

collectgarbage ()

[/code]

Now I have a temperature JSON to help graph things on Status Board, ( thanks to your huge help ) I’m curious to explore the idea of a simple Vera Status (web) widget that shows the status of my Veras.

Looking on my Edge, I only see a /sys/devices/platform/ directory with nothing apparently led-related in there. :frowning:

I did not check, but may be the suggestion from @guessed as per [url=http://forum.micasaverde.com/index.php/topic,25217.msg177528.html#msg177528]http://forum.micasaverde.com/index.php/topic,25217.msg177528.html#msg177528[/url] to look at /usr/bin/set_leds.sh still holds ?

[quote=“guessed, post:3, topic:181278”]Take a look at /usr/bin/set_leds.sh to see how the LEDs are managed on each hardware model. Looks like they’ve taken a fairly standard route and mounted them under a virtual filesystem.

I imagine you can read the values back from there to get their current status.[/quote]

Great call! This points to /sys/class/leds/ which contains, on my Edge:

na301:green:lan      na301:green:power    na301:green:service  na301:green:zwave

Therein lies the answer, I think.

Nice !!

Ok - I’m not near my VeraPlus to check - but I’m going to assume much of the getLED function is still the same other than the change of file location etc.

And rather than encode each one into a single variable (as I think like You/ @akbooer has done) - I’m going to need each variable to be seperate so I can some how present them in a table/list form with some sort of colour statue icon - based in the colour reported.

One questions - what is the full address / file name of the one used on the Vera/VeraLight - assume UI5 - as I’ll look into a way of doing both - as I have Ui5 & UI7

I don’t understand what is meant by this - I was expecting a file extension at the end ?

/sys/devices/platform/leds-gpio/leds/veralite:%s/brightness
/sys/devices/platform/leds-gpio/leds/veralite:blue:power/brightness
/sys/devices/platform/leds-gpio/leds/veralite:orange:zwave/brightness
/sys/devices/platform/leds-gpio/leds/veralite:red:error/brightness
/sys/devices/platform/leds-gpio/leds/veralite:yellow:lan/brightness

Interestingly, on the VeraLite under UI5, you also have:

# ls /sys/class/leds
veralite:blue:power    veralite:orange:zwave  veralite:red:error     veralite:yellow:lan

which are directories which contain ‘virtual’ files including, for example:

# cat /sys/class/leds/veralite\:blue\:power/brightness 
255

…so, in fact, this little code snippet should work on any machine:

local lfs = require "lfs"

local leds = {}
local leaf = "/brightness"
local root = "/sys/class/leds/"
local mcv = "(%w+):(%w+):(%w+)$"
for branch in lfs.dir (root) do
    local m,c,v = branch: match (mcv)
    if v then 
        local l = {}
        for x in io.lines (root..branch..leaf) do l[#l+1] = x end
        leds[#leds+1] = {machine = m, colour = c, functionality = v, value = l[1]}
    end
end

print (pretty(leds))

on a VeraLite this produces:

{{
    colour = "red",
    functionality = "error",
    machine = "veralite",
    value = "0"
  },{
    colour = "orange",
    functionality = "zwave",
    machine = "veralite",
    value = "255"
  },{
    colour = "yellow",
    functionality = "lan",
    machine = "veralite",
    value = "255"
  },{
    colour = "blue",
    functionality = "power",
    machine = "veralite",
    value = "255"
  }}

…and on an Edge:

{{
    colour = "green",
    functionality = "power",
    machine = "na301",
    value = "255"
  },{
    colour = "green",
    functionality = "zwave",
    machine = "na301",
    value = "255"
  },{
    colour = "green",
    functionality = "lan",
    machine = "na301",
    value = "255"
  },{
    colour = "green",
    functionality = "service",
    machine = "na301",
    value = "255"
  }}

This is close to what you need.

Thanks @akbooer

To start with I’ve designed a basic HTML table widget/panel to be used with Status Board, and I’ll now try and work out how to make it reflect the statuses of the controller.