Local time: Thu 2019-11-07 09:52:56 CST
Universal time: Thu 2019-11-07 15:52:56 UTC
RTC time: Thu 2019-11-07 15:52:57
Time zone: America/Regina (CST, -0600)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
I have a door sensor, and creat a query to grab last changed status:
- platform: sql
scan_interval: 2
queries:
- name: living to garage door last opened
query: "select last_changed from states where entity_id = 'binary_sensor.0x00158d000275ef5d_contact' and state = 'on' order by last_changed desc;"
column: 'last_changed'
value_template: "{{ as_timestamp(value) | timestamp_local }}"
But it always show UTC time on Lovelace UI.
I tested in Developer tool > Template
Yes. The last_changed column in the states table is not in a time zone aware format, so the as_timestamp() function is assuming it’s a local time. You can fix that by appending the UTC suffix this way:
I have a quick question regarding time as well, when I create new automation, what kind of time I should put on it? Currently if I put the time like this “08:00:00” then it never triggers at 8AM of local time.
If the automation is on, and there aren’t any conditions stopping it, and there’s no syntax or other errors in the action part, then it will trigger at 8AM local time. (According to what you posted above it looks like the clock and time zone settings are correct.) Can you post the entire automation (from the YAML file)?