How to store somewhere the value returned

**Hello,
I’m making this request because I’d like to retrieve the state of a lamp (color and lighting mode, fixed for example), store it somewhere, change the lamp’s state (change color and blinking), then put it back to its initial state.
**
Currently I don’t see how

Hi @Psoy :slight_smile:

You can already do this with a « Control device » action and a « virtual » device created in the MQTT integration.

  1. You create a device of the same type as the device whose state you want to save
  2. You perform a « Get last state »
  3. You perform a « Control device » with the value coming from « Get last state »
  4. You restore whenever you want with a combo « Get last state » + « Control device »

Don’t hesitate if you have any questions :slight_smile:

3 Likes

These virtual devices are really very useful (I use many of them) but I always feel that their use goes a bit unnoticed, which is a shame!

Hello @pierre-gilles, @guim31
I’ll look into that, but it’s true that I didn’t think of using a virtual

1 Like

@Psoy I’ve transformed your post into a question :slight_smile:

1 Like

Thank you @pierre-gilles