# Huemagic - cache current value and restore it after some time

**URL:** <https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569>\
**Category:** Dashboard\
**Created:** [20 October 2020 13:09 UTC](https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569 "2020-10-20T13:09:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheSoulrester](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thesoulrester/32/37842_2.png) [@TheSoulrester](https://discourse.nodered.org/u/TheSoulrester)\
**Post date:** [20 October 2020 13:09 UTC](https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569/1 "2020-10-20T13:09:29Z")

</div>

Hi 🙂

how is it possible to get the current state of all wanted hue elements (in my situation, there are only hue light bulbs) and store these information in a cache?

get the status should be the `msg.payload = any` right? but how can i save these values to restore it later again?

i'm a voluntary firefighter and i did my pager a bit smart 😉 - the charger has a relay output. as soon as the pager is in the charger and trips, the relay output closes and starts an automation like (at night) turning on lights (red, 30% brightness) and turning them off after 30s for example.

now i want that the old values (which got cached) will be restored again after the light got switched off (because i had left the house 😉 ). how will this be possible?

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [20 October 2020 15:24 UTC](https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569/2 "2020-10-20T15:24:44Z")

</div>

Are you familiar with using context variables? Global, specific flow, etc? Sounds like you should just use a flow variable to hold the value or values until needed (again).

Check out...

> **[Working with context : Node-RED](https://nodered.org/docs/user-guide/context)**

---

<div class="post-metadata">

**Author:** ![TheSoulrester](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thesoulrester/32/37842_2.png) [@TheSoulrester](https://discourse.nodered.org/u/TheSoulrester)\
**Post date:** [20 October 2020 20:02 UTC](https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569/3 "2020-10-20T20:02:14Z")

</div>

thank you 🙂

i'm completly new with node-red i'm glad to have understand how i have to set up huemagic 😉 - but i will see what you linked 😉

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [20 October 2020 23:15 UTC](https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569/4 "2020-10-20T23:15:38Z")

</div>

Sure, as you learn and have more questions, just ask.

---

<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:** [19 December 2020 23:15 UTC](https://discourse.nodered.org/t/huemagic-cache-current-value-and-restore-it-after-some-time/34569/5 "2020-12-19T23:15:39Z")

</div>

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