Help with template sensor (Xiaomi Vacuum)

Hello, I’m new to Home Assistant and I am trying to create a new template sensor for my Xiaomi Vacuum.

In my configuration.yaml I am adding:

  • platform: template
    sensors:
    vacuum_status:
    value_template: ‘{{ state.vacuum.xiaomi_vacuum_cleaner.attributes.status }}’

When I validate the configuration I receive the following error:

Invalid config for [sensor.template]: expected a dictionary for dictionary value @ data[‘sensors’][‘vacuum_status’]. Got None
expected a dictionary for dictionary value @ data[‘sensors’][‘value_template’]. Got ‘{{ state.vacuum.xiaomi_vacuum_cleaner.attributes.status }}’. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/

In the developer entities area I can see the following attributes of my vacuum:

status: Charging
battery_level: 100
battery_icon: mdi:battery-charging-100
fan_speed: Balanced
fan_speed_list: Quiet,Balanced,Turbo,Max
do_not_disturb: off
do_not_disturb_start: 22:00:00
do_not_disturb_end: 08:00:00
cleaning_time: 0
cleaned_area: 0
cleaning_count: 169
total_cleaned_area: 6307
total_cleaning_time: 6684
main_brush_left: 188
side_brush_left: 88
filter_left: 38
friendly_name: Xiaomi Vacuum cleaner
supported_features: 2047

Did anyone created somtehing similar? Can you help me?

Thanks!!!

Mine is set up like this:

    wentworth_status:
      friendly_name: "Wentworth Status"
      value_template: >-
        {{ states.vacuum.wentworth.attributes.status }}

Thanks martamoonpie.

I have changed the configuration so now it is similar like yours, but I see the same error :frowning:

I have read all the documentation and I don’t know if I understood the concept regarding.

My goal is add in my configuration.yaml file the definition of the sensor (in my first message there is the config). And in automation.yaml I will check the sensor as a trigger.

Now I am in the phase of adding the sensor template in the configuration file.

I finally solved the issue. Now my configuration.yaml is:

  • platform: template
    sensors:
    vacuum_status:
    value_template: ‘{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.status }}’

and my automation.yaml is:

alias: Chachaomi_limpiando
trigger:

  • platform: state
    entity_id: sensor.vacuum_status
    from: Charging
    to: Cleaning
    action:
  • data:
    entity_id: automation.activa_alarma
    service: automation.turn_off
1 Like