Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner authored Jan 4, 2024
1 parent dddcb14 commit 4ad7bc4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) }}
```

0 comments on commit 4ad7bc4

Please sign in to comment.