# Save/Restore Current State

**URL:** <https://wled.discourse.group/t/save-restore-current-state/404>\
**Category:** Enhancements\
**Created:** [May 7, 2020, 4:29pm UTC](https://wled.discourse.group/t/save-restore-current-state/404 "2020-05-07T16:29:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 7, 2020, 4:29pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/1 "2020-05-07T16:29:26Z")

</div>

Here’s another… Would anyone else be interested in being able to Save/Restore the current state? Just a basic, push/pop type of thing. Either as functions, or API-calls for use in macros?

---

<div class="post-metadata">

**Author:** ![Aircoookie](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aircoookie/32/2_2.png) [@Aircoookie](https://wled.discourse.group/u/Aircoookie)\
**Post date:** [May 7, 2020, 6:25pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/2 "2020-05-07T18:25:59Z")

</div>

I’m sure I’m misunderstanding you here… this sounds exactly like what Presets do. How do you want this to work?

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 7, 2020, 6:31pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/3 "2020-05-07T18:31:52Z")

</div>

I’m trying to do this _without_ using up a slot (or using the _only_ slot, for now, if using segments).

My particular application would be to run macro x when the input is active, then restore what was going on before when it goes inactive. I already have the code setup to handle the input.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 7, 2020, 8:25pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/4 "2020-05-07T20:25:52Z")

</div>

I suppose I could use &PS=16 and &PL=16 for now.

---

<div class="post-metadata">

**Author:** ![Aircoookie](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/aircoookie/32/2_2.png) [@Aircoookie](https://wled.discourse.group/u/Aircoookie)\
**Post date:** [May 7, 2020, 11:40pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/5 "2020-05-07T23:40:08Z")

</div>

Actually there is a neat little undocumented feature that could be helpful for you. If you do `PS=16&NP` the preset will be saved to ram only and not yet persistently to flash memory. This prevents flash wearout if you use the command often 🙂

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 7, 2020, 11:42pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/6 "2020-05-07T23:42:07Z")

</div>

Nice. then I could do a `PL=16`?

**Update**  
I found I had to add the NP stuff to 091. 🤣  
I have this for macro 1: `&PS=16&NP&TT=0&FX=0&R=255&G=0&B=0`  
and this for macro 2: `&PL=16`

Something is stepping on something else as slot 16 ends up being saved as red. I even moved the code to handle the saving up to the top in wled\_set.

---

<div class="post-metadata">

**Author:** ![huggy-d1](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/huggy-d1/32/51_2.png) [@huggy-d1](https://wled.discourse.group/u/huggy-d1)\
**Post date:** [May 8, 2020, 2:12pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/7 "2020-05-08T14:12:08Z")

</div>

It’s in the wiki now. Hopefully semi-correctly placed.

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 8, 2020, 5:35pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/8 "2020-05-08T17:35:01Z")

</div>

Working now!

---

<div class="post-metadata">

**Author:** ![huggy-d1](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/huggy-d1/32/51_2.png) [@huggy-d1](https://wled.discourse.group/u/huggy-d1)\
**Post date:** [May 8, 2020, 6:14pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/9 "2020-05-08T18:14:23Z")

</div>

What did you change from 19 hrs ago?

---

<div class="post-metadata">

**Author:** ![tonyno](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/tonyno/32/242_2.png) [@tonyno](https://wled.discourse.group/u/tonyno)\
**Post date:** [May 8, 2020, 6:37pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/10 "2020-05-08T18:37:53Z")

</div>

Since I’m still on 091, I had to pull the NP code in.

---

<div class="post-metadata">

**Author:** ![Def3nder](https://yyz2.discourse-cdn.com/free1/user_avatar/wled.discourse.group/def3nder/32/62_2.png) [@Def3nder](https://wled.discourse.group/u/Def3nder)\
**Post date:** [November 27, 2020, 5:55pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/11 "2020-11-27T17:55:56Z")

</div>

Hi,

I just updated to 0.11 and changed my son’s old sunrise effect (using Nightlight and Color-fade) to the new way of using the Effect “Sunrise” with this Preset settings:

{ “bri”: 128,  
“udpn”: { “nn”: true },  
“seg”: { “fx”: 104, “sx”: 10, “ix”: 255, “pal”: 35 }}

The **“udpn”: { “nn”: true }** has the effect that other syncronized WLED instances are not being notified - very usefull 🙂

My only problem with thiis is, that the WLED state **BEFORE the sunrise** is gone after using this preset.

I would like to save the state, load this preset und one hour later restore the prevvious state.

I tried to call a macro with “PS=99” and then “PL=99” later, but this did not work (as in the then saved “Preset 99” the currect state wasn’t incuded ☹ - instead “PS=99” was in there)

…any suggestions how to solve this ?

Is there a way to tell WLED via a JSON Object to save the current state ?

@Aircoookie what has been the reason why the "save to memory feature (&NP) was removed in Build 2011152 ? This would be perfect for me as the “save current state”-solution would be triggered once a day and would lead to 365 saves to the flash per year.

---

<div class="post-metadata">

**Author:** ![Walfy07](https://avatars.discourse-cdn.com/v4/letter/w/839c29/32.png) [@Walfy07](https://wled.discourse.group/u/Walfy07)\
**Post date:** [November 29, 2022, 2:21pm UTC](https://wled.discourse.group/t/save-restore-current-state/404/12 "2022-11-29T14:21:29Z")

</div>

Is there any update to this?

I’m looking for a way to have WLED resume the last playlist/preset after power cycles?
