How to make a condition based on a past state?

Hi,

I’ve a siemens connected dishwasher, I would like to start it automatically when I generate enough solar panel(let’s say at least that I export at least 2kw).

The 2kw part is easy, but I’m strugling to check if the diswhaser is in a state where I can start it:

I’ve several state for it:
Operation State: (Run, Ready, Finished)
Door: (Open, Closed)

So my first try was to say, when I produce enough, and that the dishwasher door is closed and the state is ready, then launch the dishwasher. Here is my automation:

description: "Start dishwasher when enough power"
mode: single
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.grid_export_power
    for:
      hours: 0
      minutes: 15
      seconds: 0
    above: 2
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.lave_vaisselle_door
        state: "off"
      - condition: state
        entity_id: sensor.lave_vaisselle_operation_state
        state: Ready
        for:
          hours: 0
          minutes: 5
          seconds: 0
action:
  - type: turn_on
    device_id: af59a88273788a4573d17914afb5eff4
    entity_id: 91d39579b6451f67df418b8e4f5565ef
    domain: switch
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.lave_vaisselle_power

The issue is that the dishwasher stay in the “Finished” state for just 1 min, and then goes in the “ready mode”.

So when I produce enough, my dishwasher goes in an infinite loop of washing cycle.

I wish I could say: only run this when the door has been through the door state “Open”, after the state has been set to Finished/Ready.

Basically to say that the door has been opened since the last time it finished(which would mean we did unloaded it).

Any idea how to have such complex condition? I’m lost, because this involve some “timing”.

You could use a helper toggle (input_boolean) to keep track of this extra bit of state information for you.

I’d call it input_boolean.dishes_dirty, but you might want to call it something else. Set up an automation so that any time the dishwasher goes in to Finish state, the toggle gets set to false. Then another that turns it to true whenever the door is open.

Finally, update your original automation to have a condition that dishes dirty must be true in order to start the dishwasher.

That’s so smart and elegant! Thank you very much!
Trying this now, I will let you know :slight_smile: