Do I use a sensor for this?

I would like to create two entities: washer_status and dryer_status. The value of each will be one of three values: “Powered off”, “Idle” and “Running”.

The power switch will determine powered off and idle.
My automations use the blueprint “Appliance has finished” which will determine the idle and running status.

Can I use a sensor to record these values?

I would like to display it like this
status

I do something similar with that blueprint, but I only use “on/off”. The “trick” is to raise a custom event in both action inputs of the blueprint to trigger a template sensor. In my event data I include a state variable. So for the “Actions when starting threshold is crossed” input you could use something like:

event: custom_sensor_washing_machine
event_data:
  state: "running"

The trigger-based template sensor then includes triggers for any events used in the blueprint automation, and in your case you would have one for the power sensor as well:

template:
  - trigger:
      - platform: numeric_state
        entity_id: sensor.washer_power
        below: 2
        for: "00:10:00"
        id: "off"
      - platform: event
        event_type: custom_sensor_washing_machine
        event_data:
          state: running
        id: running
      - platform: event
        event_type: custom_sensor_washing_machine
        event_data:
          state: idle
        id: idle
    sensor:
      - name: "Washer Status"
        state: >
          {{ trigger.id | default('off') }}

EDIT: Removed incorrect device class

Thank you @Didgeridrew this is a tremendous help.

I must have done something wrong. I set up the two templates in config.yaml, checked the configuration, and did a restart. I then added, modified, and ran all of triggering automations. When I look at the traces for the automations, I see no errors - everything completed. I then went to add the sensor to my dashboard and can’t find it. I used developer tools, devices, entities and see nothing for sensor.Washer_Status or sensor.Dryer_Status. This is what I am looking for - correct? Do you have any idea what I may be doing wrong?

They should be in the Entities tab, not Devices. Based on what you posted, I would expect their entity IDs to be sensor.washer_status and sensor.dryer_status.

Are you using the Filebrowser add-on? For some reason that add-on seems to direct people to a file that it generates named config.yaml instead of the correct file which is configuration.yaml.

If you actually placed the templates in configuration.yaml and just abbreviated it in your post, then post a screen shot or the configuration of what you did so we can see where the issue might be.

I looked in both devices and entities.
Yes, it was just an abbreviations for configuration.yaml - I use Studio Code Server.

configuration.yaml entries:

  # washer
  - trigger:
      - platform: event
        event_type: custom_sensor_washing_machine
        event_data:
          state: power_off
        id: "power off"
      - platform: event
        event_type: custom_sensor_washing_machine
        event_data:
          state: running
        id: running
      - platform: event
        event_type: custom_sensor_washing_machine
        event_data:
          state: idle
        id: idle
    sensor:
      - name: "Washer Status"
        device_class: running
        state: >
          {{ trigger.id | default('power_off') }}

  # dryer
  - trigger:
      - platform: event
        event_type: custom_sensor_dryer
        event_data:
          state: power_off
        id: "power off"
      - platform: event
        event_type: custom_sensor_dryer
        event_data:
          state: running
        id: running
      - platform: event
        event_type: custom_sensor_dryer
        event_data:
          state: idle
        id: idle
    sensor:
      - name: "Dryer Status"
        device_class: running
        state: >
          {{ trigger.id | default('unknown') }}

Nope, I inadvertently led you astray when I left the device class in my example… running is a valid device class for binary sensors but not for sensors. Erase the device_class lines, save, and reload.

@Didgeridrew that was it! Thank you so-o-o much. I don’t know how long that would have taken me to find. It threw no errors either - I had looked through all of the logs. The other frustrating thing was that none of the automations had errors either. I had searched on device_class too but couldn’t find any information that told me I couldn’t use “running”. I’m sure it’s out there - just always hard for the relative newer user to find. So another good learning experience.

1 Like

I did exactly this some time ago. But finally settled for a simple binary sensor.

@odwide I originally looked at the binary sensor but I wanted to have 3 states since we actually power off the units when they are not in use. If we didn’t do this, it would be easy to use a binary sensor. So far this solution is working well - the washer is running and status has changed correctly.