Add attribute templates to template vacuum (#13733)

Co-authored-by: Klaas Schoute <klaas_schoute@hotmail.com>
This commit is contained in:
Chris 2020-06-22 17:25:59 -07:00 committed by GitHub
parent 4ea8f695ba
commit 1511c94bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 %}