I have a similar error like above, but I’m not sure exactly where the problem is.
Running Hassio
Got my recorder running on mariadb as an addon from hassio
Timezone is set to Europe/Stockholm in configuration.yaml.
Everything in the GUI is correct, looking at the history of a device shows the correct time, but if I do a value_template on the “last_changed” attribute, that time is 2 hours wrong. (seems to be using UTC time).
I just did a reebot of my server at 21:10 (24h time) and below template gives me “19:10”
@pnbruckner - Apparently I didn’t check my phone last time but it’s showing -7 hours now (time without applying the timezone) while my laptop is showing the time with the time zone applied (ie - 8 seconds).
Do you have any thoughts on why there could be this discrepancy?
I posted the views above that appear to show both browsers are calculating the same numbers when using the templates dates.
all i understand that it Hassio is using UTC while writing in the database as default ,i want to change the writing in database instead of UTC to EET ,do u know to change that? @pnbruckner
the history that i read from database i want to view it but it give me UTC ,and i want in EET ,it will force me to make changes in my query @pnbruckner or if u have another idea
Maybe you need to describe where and how this querying of the database will be done. Are you doing this in Home Assistant (HA), or in something else? If you’re doing it in HA, there might be another way to solve your problem. Again, it would be helpful to understand what you’re ultimately trying to achieve.
@pnbruckner yes i’m using latest version of HA ,i’m trying to get lastest read about Voltage sensor and last datetime and see the history of it ,so i call from database of homeassistant2.db that give me created datetime ,so it give me in UTC which is wrong time ,so i want it in correct time which is EET as 2 hours different .
see the snapshot of my HA 101.2
see the history said correct time is 16:11 but in the Volt date time in the database is 14:11 picture upload
Why aren’t you just using the values available in the entity’s State Object? For example, if you want to know when the state last changed, you do not have to do a complicated database query, you can just use:
- 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 }}"