template: - binary_sensor: - name: Washing Machine unique_id: templatebinarysensor.washing_machine delay_on: "{{states('input_number.washing_machine_delay_on') | float(default=0)}}" delay_off: "{{states('input_number.washing_machine_delay_off') | float(default=0)}}" icon: mdi:washing-machine availability: "{{ states('sensor.pm_laundry_plug_w') not in ['unknown', 'unavailable'] }}" attributes: model_number: "WF45R6100AW/US" serial_number: "01FY57AM802740X" power: "{{ states('sensor.pm_laundry_plug_w') | float(default=0)}}" target: "{{ states('input_number.washing_machine_on') | float(default=0)}}" state: "{{ states('sensor.pm_laundry_plug_w')|float(default=0) >= states('input_number.washing_machine_on')|float(default=0) }}" - sensor: - name: Washing Machine unique_id: templatesensor_washing_machine state: > {% if is_state('binary_sensor.washing_machine','on') %} running {% elif is_state('binary_sensor.washing_machine','off') and is_state('input_boolean.swap_laundry','on') %} pending {% else %} idle {% endif %} icon: > {% if is_state('sensor.washing_machine','idle') %} mdi:washing-machine-off {% elif is_state('sensor.washing_machine','pending') %} mdi:washing-machine-alert {% else %} mdi:washing-machine {% endif %} attributes: model_number: "WF45R6100AW/US" serial_number: "01FY57AM802740X" power: "{{ states('sensor.pm_laundry_plug_w') | float(default=0)}}" target: "{{ states('input_number.washing_machine_on') | float(default=0)}}" input_boolean: swap_laundry: name: Swap Laundry icon: mdi:tshirt-crew input_number: washing_machine_on: # was 5 name: "Washing Machine On" icon: mdi:washing-machine min: 0 max: 20 step: 0.1 mode: box unit_of_measurement: W washing_machine_off: name: "Washing Machine Off" icon: mdi:washing-machine-off min: 0 max: 20 step: 0.1 mode: box unit_of_measurement: W washing_machine_delay_on: name: "Washing Machine Delay On" icon: mdi:clock min: 0 max: 900 step: 10 mode: box washing_machine_delay_off: # was 10 name: "Washing Machine Delay Off" icon: mdi:clock-alert min: 0 max: 900 step: 10 mode: box automation: - id: automation_swap_laundry_state alias: Swap Laundry trigger: - id: washing_machine_off platform: state entity_id: binary_sensor.washing_machine from: "on" to: "off" - id: washing_machine_on platform: state entity_id: binary_sensor.washing_machine from: "off" to: "on" - id: door_open platform: state entity_id: binary_sensor.washing_machine_door_contact from: "off" to: "on" for: seconds: 5 condition: [] action: - choose: - alias: "Washing machine is running. No need to swap laundry yet" conditions: - condition: trigger id: washing_machine_on - condition: state entity_id: input_boolean.swap_laundry state: "on" sequence: - service: logbook.log data_template: name: Swap Laundry - Load started entity_id: automation.swap_laundry message: Washing machine is running. No need to swap laundry yet. Turning off input_boolean.swap_laundry, in case it was left on - service: homeassistant.turn_off target: entity_id: input_boolean.swap_laundry - alias: "Washing machine finished while door was shut" conditions: - condition: trigger id: washing_machine_off - condition: state entity_id: binary_sensor.washing_machine_door_contact state: "off" sequence: - service: logbook.log data_template: name: Swap Laundry - Load needs to be swapped entity_id: automation.swap_laundry message: Washing machine turned off while the door was shut. Assuming that a load needs to be swapped - service: homeassistant.turn_on target: entity_id: input_boolean.swap_laundry - alias: "Door was opened while washing machine was off" conditions: - condition: trigger id: door_open - condition: state entity_id: binary_sensor.washing_machine state: "off" - condition: state entity_id: input_boolean.swap_laundry state: "on" sequence: - service: logbook.log data_template: name: Swap Laundry - Load swapped entity_id: automation.swap_laundry message: Door was opened while washing machine was off. Assuming a load just got swapped - service: homeassistant.turn_off target: entity_id: input_boolean.swap_laundry mode: single