Input_select using from_state

Hi,

A simple problem that I’ve now spent too many hours trying to figure out…

I need to record the previous state of an input_select so that its state can be returned to in future.

So I have created two input_selects;

input_select:
  set_water_heater_mode:
    name: Water Heater Mode
    options:
      - Manual
      - Eco
      - Smart
      - Timer
      - Travel
      - Boost
  previous_water_heater_mode:
    name: Previous Water Heater Mode
    options:
      - Manual
      - Eco
      - Smart
      - Timer
      - Travel
      - Boost


When the first one changes, the second needs to be set to the previous value of the first.

- id: Water Heater Previous Mode
  alias: Water Heater Previous Mode
  trigger:
  - platform: state
    entity_id: input_select.set_water_heater_mode
  action:
    - service: input_select.select_option
      target:
        entity_id: input_select.previous_water_heater_mode
      data:
        option: "{{ states.trigger.from_state.state }}"


It doesn’t work, what am I getting wrong here?

Thank you

Replace this:

        option: "{{ states.trigger.from_state.state }}"

with this:

        option: "{{ trigger.from_state.state }}"

For more information, refer to Templates – State Trigger

1 Like

Was sure I tried that before and it didn’t work - but it works perfect now.

Thank you.

The simple things seem to trip me up. I’m off work with covid and I’ve spent the last 3 days solid building stuff in node red. Really should do something else now.

1 Like