From 942cfde7c21c09f7f880fa1c560db5e896112746 Mon Sep 17 00:00:00 2001 From: heyajohnny Date: Fri, 13 Sep 2024 21:33:29 +0200 Subject: [PATCH] format_date fix --- Version | 3 ++- custom_components/afvalinfo/hacs.json | 8 ++++++-- custom_components/afvalinfo/manifest.json | 2 +- custom_components/afvalinfo/sensor.py | 10 ++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Version b/Version index aae059b..3ef8883 100644 --- a/Version +++ b/Version @@ -200,4 +200,5 @@ version: 2.0.8 20231217 - Use friendly name of other sensors in the today and t version: 2.1.0 20240428 - Update existing sensor is now available (so you don't need to delete and re-add it) version: 2.1.1 20240603 - Possible fix for ConfigFlowResults error version: 2.1.2 20240713 - Fix config entry setup warning -version: 2.1.3 20240718 - http -> https \ No newline at end of file +version: 2.1.3 20240718 - http -> https +version: 2.1.4 20240913 - format_date fix \ No newline at end of file diff --git a/custom_components/afvalinfo/hacs.json b/custom_components/afvalinfo/hacs.json index 0690ce6..05965d3 100644 --- a/custom_components/afvalinfo/hacs.json +++ b/custom_components/afvalinfo/hacs.json @@ -2,7 +2,11 @@ "name": "Afvalinfo", "content_in_root": false, "render_readme": true, - "domains": ["sensor"], - "country": ["NL"], + "domains": [ + "sensor" + ], + "country": [ + "NL" + ], "homeassistant": "0.100.0" } \ No newline at end of file diff --git a/custom_components/afvalinfo/manifest.json b/custom_components/afvalinfo/manifest.json index b49f44f..b17d257 100644 --- a/custom_components/afvalinfo/manifest.json +++ b/custom_components/afvalinfo/manifest.json @@ -1,7 +1,7 @@ { "domain": "afvalinfo", "name": "Afvalinfo", - "version": "2.1.3", + "version": "2.1.4", "config_flow": true, "iot_class": "cloud_polling", "documentation": "https://github.com/heyajohnny/afvalinfo", diff --git a/custom_components/afvalinfo/sensor.py b/custom_components/afvalinfo/sensor.py index d5d376a..eb38dab 100644 --- a/custom_components/afvalinfo/sensor.py +++ b/custom_components/afvalinfo/sensor.py @@ -53,6 +53,11 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +async def async_format_date(hass, collection_date, half_babel_half_date, locale): + return await hass.async_add_executor_job( + format_date, collection_date, half_babel_half_date, locale + ) + async def async_setup_entry( hass: HomeAssistant, config_entry: config_entries.ConfigEntry, @@ -366,10 +371,11 @@ async def async_update(self): r"(\d+)", r"'\1'", half_babel_half_date ) # transform the EEE, EEEE etc... to a real locale date, with babel - locale_date = format_date( + locale_date = await async_format_date( + self.hass, collection_date, half_babel_half_date, - locale=self.locale, + self.locale, ) self._state = locale_date