# Store values in case power goes off

**URL:** <https://discourse.nodered.org/t/store-values-in-case-power-goes-off/89799>\
**Category:** Dashboard\
**Created:** [26 July 2024 19:25 UTC](https://discourse.nodered.org/t/store-values-in-case-power-goes-off/89799 "2024-07-26T19:25:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xfear1](https://avatars.discourse-cdn.com/v4/letter/x/4da419/32.png) [@xfear1](https://discourse.nodered.org/u/xfear1)\
**Post date:** [26 July 2024 19:25 UTC](https://discourse.nodered.org/t/store-values-in-case-power-goes-off/89799/1 "2024-07-26T19:25:49Z")

</div>

Hello!  
I am having the an issue, if I turn off my computer or power goes off every data my chart collected just disapears, is there a way to store the values and not lose it?  
Can anyone help me with that?

---

<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:** [26 July 2024 20:24 UTC](https://discourse.nodered.org/t/store-values-in-case-power-goes-off/89799/2 "2024-07-26T20:24:04Z")

</div>

I save sensor data in a database as I receive it & use SQL to extract and format it for the chart.

No doubt you could save it into persistent context variables if you don't want the faff of a database.

Stored data sent to a chart needs to be in a rather different format than live data, see the chart node's help for examples.

---

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [28 July 2024 20:11 UTC](https://discourse.nodered.org/t/store-values-in-case-power-goes-off/89799/3 "2024-07-28T20:11:12Z")

</div>

You save the data out of the chart node to a file, and on startup read that file back in.

An example flow would be something like this:

```auto
[{"id":"9b4ec05b1a202367","type":"ui_chart","z":"7aea2353258f6a1c","name":"Graph","group":"226d5b24d8765c69","order":2,"width":"7","height":4,"label":"Graph 1","chartType":"line","legend":"true","xformat":"dd HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":"","useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":710,"y":340,"wires":[["09a617226726e186"]]},{"id":"09a617226726e186","type":"file","z":"7aea2353258f6a1c","name":"Save Data","filename":"GRAPH_FILENAME.json","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"utf8","x":870,"y":340,"wires":[[]]},{"id":"1ef4be40878d02f7","type":"json","z":"7aea2353258f6a1c","name":"","x":550,"y":360,"wires":[["9b4ec05b1a202367"]]},{"id":"7ef0deab71278d45","type":"file in","z":"7aea2353258f6a1c","name":"Load Data","filename":"GRAPH_FILENAME.json","filenameType":"str","format":"utf8","allProps":false,"x":390,"y":360,"wires":[["1ef4be40878d02f7"]]},{"id":"090327694cb33811","type":"inject","z":"7aea2353258f6a1c","name":"Restore","props":[],"repeat":"","crontab":"","once":true,"onceDelay":"","topic":"","x":220,"y":360,"wires":[["7ef0deab71278d45"]]},{"id":"8d030db1d1475ee7","type":"link in","z":"7aea2353258f6a1c","name":"INPUT DATA","links":[],"x":530,"y":320,"wires":[["9b4ec05b1a202367"]],"l":true},{"id":"226d5b24d8765c69","type":"ui_group","name":"Testing Group","tab":"8aa1072b76950fed","order":1,"disp":true,"width":7,"collapse":false,"className":""},{"id":"8aa1072b76950fed","type":"ui_tab","name":"TESTING","icon":"build","order":2,"disabled":false,"hidden":false}]

```

Feed your chart data in to the `INPUT DATA` Link In node, and make sure you put in a valid path for both the Save and Load data nodes. I have used this many times to reload graph information.

---

<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:** [27 August 2024 20:11 UTC](https://discourse.nodered.org/t/store-values-in-case-power-goes-off/89799/4 "2024-08-27T20:11:49Z")

</div>

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