# Table overview of battery level of all sensors and devices

**URL:** <https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763>\
**Category:** General\
**Created:** [27 December 2022 11:08 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763 "2022-12-27T11:08:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Falfango](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Falfango](https://discourse.nodered.org/u/Falfango)\
**Post date:** [27 December 2022 11:08 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/1 "2022-12-27T11:08:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [27 December 2022 14:32 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/2 "2022-12-27T14:32:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Falfango](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Falfango](https://discourse.nodered.org/u/Falfango)\
**Post date:** [27 December 2022 15:21 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/3 "2022-12-27T15:21:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 December 2022 15:26 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/4 "2022-12-27T15:26:03Z")

</div>

> [@Falfango](#):
>
> how can I replace an existing value of a specific topic with the new value.

Use a change node

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 December 2022 15:43 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/5 "2022-12-27T15:43:34Z")

</div>

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

```auto
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.

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/451b57ed2702d08413ec5e5cf9e31b68d51493d3.jpeg)

---

<div class="post-metadata">

**Author:** ![Falfango](https://avatars.discourse-cdn.com/v4/letter/f/5e9695/32.png) [@Falfango](https://discourse.nodered.org/u/Falfango)\
**Post date:** [27 December 2022 21:26 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/6 "2022-12-27T21:26:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 January 2023 21:27 UTC](https://discourse.nodered.org/t/table-overview-of-battery-level-of-all-sensors-and-devices/72763/7 "2023-01-10T21:27:17Z")

</div>

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