Table overview of battery level of all sensors and devices

Hi,

I want to have a table in dashobard, which shows the actual battery level of all sensors and devices. The information of the battery levels come in different times and I want to replace the previous value with the actual. My first thought was to use influxdb. But as I'm not interested in the history, this will be an overkill. Has anyone an idea, how I can feed the values into a table and show them at once in the dashboard?

If you can show the msg format of your data it would be easier.

But generally I would suggest you store the incoming data in a flow variable based on the topics of the messages.

Then just send this to the table at intervals.

Msg format is different. So previous of storage I have to convert it into format for the table anyway (e.g. topic=name, payload=value). Thats the easy thing. If I will use a flow variable, how can I replace an existing value of a specific topic with the new value.

Use a change node

I find the easiest way to handle this sort of data is with a function context storage as an object.
Like this

let batteries = context.get("batteries") ?? {} // If it doesn't already exist, initialise as object
batteries[msg.topic] = msg.payload
context.set("batteries", batteries)
// Now format msg.payload to feed to table (or in this case, a debug node)
msg.payload = batteries
return msg;

I prefer a function over Zenofmud's change node because it is easy to initialise the context store. Probably you can do that in a change node too.

Edit: Yup, very easy except you have to use flow. instead of context.

Thx! I will look into it if a function node or change node will do it best :).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.