Roomba status device

I’m trying to create a template sensor for the status of my roomba, like this:

- platform: template
  sensors:
    roomba_status:
      friendly_name: "Status"
      entity_id: vacuum.roomba_status
      value_template: "{{ state_attr('vacuum.roomba', 'status') }}"
      icon_template: "{{ state_attr('vacuum.roomba', 'battery_icon')}}"

But the only values I get for state and icon are “None”.
When I look at the vacuum.roomba device, the attributes are:

    status: Stopped
    battery_level: 89
    battery_icon: mdi:battery-90
    bin_present: true
    software_version: v2.4.6-3
    position: (173, 0, 0)
    bin_full: false

What’s wrong with my device?

Please format your code.

Sorry, but I’ve tried, and that button only gives me the straight left margin.

Try this:

Enter three back-quotes ``` on a separate line before your code.
Enter three back-quotes on a separate line after your code.

Nice! I learn something useful every day. Thanks!

Replace:

entity_id: vacuum.roomba_status

with:

entity_id: vacuum.roomba

Like this:

- platform: template
  sensors:
    roomba_status:
      friendly_name: "Status"
      entity_id: vacuum.roomba
      value_template: "{{ state_attr('vacuum.roomba', 'status') }}"
      icon_template: "{{ state_attr('vacuum.roomba', 'battery_icon')}}"

Great, it works! Thank you so very much :slight_smile: