diff --git a/source/_integrations/vacuum.template.markdown b/source/_integrations/vacuum.template.markdown index 4cc89d1b6f8..2ff3b7c1b18 100644 --- a/source/_integrations/vacuum.template.markdown +++ b/source/_integrations/vacuum.template.markdown @@ -51,6 +51,15 @@ vacuum: description: Defines a template to get the fan speed of the vacuum. required: false type: template + attribute_templates: + description: Defines templates for attributes of the sensor. + required: false + type: map + keys: + "attribute: template": + description: The attribute and corresponding template. + required: true + type: template availability_template: description: Defines a template to get the `available` state of the component. If the template returns `true`, the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available`. required: false @@ -158,3 +167,28 @@ vacuum: ``` {% endraw %} + +### Add Custom Attributes + +This example shows how to add custom attributes. + +{% raw %} +```yaml +vacuum: + - platform: template + vacuums: + living_room_vacuum: + value_template: "{{ states('sensor.vacuum_state') }}" + battery_level_template: "{{ states('sensor.vacuum_battery_level')|int }}" + fan_speed_template: "{{ states('sensor.vacuum_fan_speed') }}" + attribute_templates: + status: >- + {% if (states('sensor.robot_vacuum_robot_cleaner_movement') == "after" and states('sensor.robot_vacuum_robot_cleaner_cleaning_mode') == "stop") %} + Charging to Resume + {% elif states('sensor.robot_vacuum_robot_cleaner_cleaning_mode') == "auto" %} + Cleaning + {% else %} + Charging + {% endif %} +``` +{% endraw %}