davesmeghead / visonic

Visonic Custom Component for integration with Home Assistant
Apache License 2.0
90 stars 20 forks source link

Problem with dates #161

Open ldupont226 opened 3 days ago

ldupont226 commented 3 days ago

Hello Dave, I don't know since which version I have this date problem but I didn't have this problem in the past (version 8.6...). I'm having difficulty using dates from the integration. I always have to convert date format with strptime. Whether with the dates of lasteventtime or last_tripped_time. It seems that the dates are not recognized as dates. My Home Assistant is configured French Canadian. I am currently using version 0.9.9.3 Home assistant 2024.10.0 Is this normal?

{{state_attr("alarm_control_panel.visonic_alarm","lasteventtime")}}
Result: 02/10/2024, 15:11:33 {{as_datetime(state_attr("alarm_control_panel.visonic_alarm","lasteventtime"))}}
Result: None {{as_datetime(strptime(state_attr("alarm_control_panel.visonic_alarm","lasteventtime"),"%d/%m/%Y, %H:%M:%S"))}} Result : 2024-10-02 15:11:33

Thanks

config_entry-visonic.json

davesmeghead commented 1 day ago

You're correct in that I made all outputting of the date in the same format. And I can see where the chosen format is a problem as different parts of the world use different formats.

So what do you suggest as the date format? I'm open to suggestions that standardise it in any timezone for date formatting.

davesmeghead commented 1 day ago

When HA events are generated they set the time format like this image

I'll change the integration to do the same

ldupont226 commented 1 day ago

Hello Dave, I can't tell you which format is the right one. But if I compare the other integrations which return dates, they resemble the one you propose. I will be happy to test it. Always a big thank you for your quick response and your great work.

davesmeghead commented 1 day ago

Hi, I've changed it to what I proposed and uploaded 0.9.9.5 to Github. It's a proper time format including the UTC offset so can be converted to any local times as needed.

Note that release 0.9.9.4 added a Siren Entity as described here so you'll get that change as well.

ldupont226 commented 1 day ago

It's perfect, You are a real machine Thank you so much