From 4ad7bc4ffbb052cdc9ebe05d98461761d0e4e37c Mon Sep 17 00:00:00 2001 From: Phil Bruckner Date: Thu, 4 Jan 2024 12:09:04 -0600 Subject: [PATCH] Update README.md --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c383a58..77279b5 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ Creates sensors that have details (time zone, address, etc.) about another entit Type | Description -|- address | The address where the entity is located -country | The country the entity is in. Includes an attribute with the country code. +country | The country the entity is in. Includes a `country_code` attribute. different country | Is `on` when the country where entity is located is different than Home Assistant's country configuration different time | Is `on` when the local time where entity is located is different than Home Assistant's local time -local time | The local time where the entity is located. No time zone suffix is included so that the UI doesn't automatically change it back to Home Assistant's local time. -time zone | The name of the time zone where the entity is located +local time | The local time where the entity is located. No time zone suffix is included so that the UI doesn't automatically change it back to Home Assistant's local time. Includes a `time` attribute with a time zone "aware" Python `datetime` object. +time zone | The name of the time zone where the entity is located. Includes a `utc_offset` attribute. All entities are disabled by default, exept for the "local time" sensor, which is enabled by default for static time zones and zone entities, @@ -55,3 +55,14 @@ recorder: - sensor.*_address - sensor.*_local_time ``` + +## Template Example + +It is possible to use the `time` attribute of the "local time" sensor to convert other +Python `datetime` or `time` objects to the same time zone. +For example: +```yaml +{% set test = states('input_datetime.test')|as_datetime|as_local %} +{{ test }} +{{ test.astimezone(state_attr('sensor.abc_local_time', 'time').tzinfo) }} +```