From 82762d63da0b2066d7884936ba8edb1ba90dda3b Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 2 Apr 2024 09:29:37 +0200 Subject: [PATCH] Add floor template functions (#32121) * Add floor template functions * Add missing full stop --- .../_docs/configuration/templating.markdown | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index f2bd16b9b7a..96a66407429 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -458,6 +458,51 @@ The same thing can also be expressed as a test: {% endraw %} +### Floors + +- `floors()` returns the full list of floor IDs. +- `floor_id(lookup_value)` returns the floor ID for a given device ID, entity ID, area ID, or area name. Can also be used as a filter. +- `floor_name(lookup_value)` returns the floor name for a given device ID, entity ID, area ID, or floor ID. Can also be used as a filter. +- `floor_areas(floor_name_or_id)` returns the list of area IDs tied to a given floor ID or name. Can also be used as a filter. + +#### Floors examples + +{% raw %} + +```text +{{ floor() }} # ['floor_id'] +``` + +```text +{{ floor_id('First floor') }} # 'first_floor' +``` + +```text +{{ floor_id('my_device_id') }} # 'second_floor' +``` + +```text +{{ floor_id('sensor.sony') }} # 'first_floor' +``` + +```text +{{ floor_name('first_floor') }} # 'First floor' +``` + +```text +{{ floor_name('my_device_id') }} # 'Second floor' +``` + +```text +{{ floor_name('sensor.sony') }} # 'First floor' +``` + +```text +{{ floor_areas('first_floor') }} # ['living_room', 'kitchen'] +``` + +{% endraw %} + ### Areas - `areas()` returns the full list of area IDs