From 0c48c4f7ac2943bbf3f5c724576fe077cc62fc45 Mon Sep 17 00:00:00 2001 From: Nuhser Date: Thu, 4 Jan 2024 21:51:26 +0100 Subject: [PATCH 1/2] Fix bug with unit conversion Radius was converted from feet to meter when Home Assistant is set to use metric system instead of the other way around. --- custom_components/nextbike/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/nextbike/sensor.py b/custom_components/nextbike/sensor.py index 10cc948..ebcfa46 100644 --- a/custom_components/nextbike/sensor.py +++ b/custom_components/nextbike/sensor.py @@ -138,7 +138,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= longitude = config.get(CONF_LONGITUDE, hass.config.longitude) radius = config.get(CONF_RADIUS) name = config.get(CONF_NAME) - if hass.config.units is METRIC_SYSTEM: + if hass.config.units is not METRIC_SYSTEM: radius = DistanceConverter.convert( radius, UnitOfLength.FEET, UnitOfLength.METERS ) From cc862a5c30a986cc7823f6d293639bab30f938f6 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 24 Oct 2024 17:43:12 +0200 Subject: [PATCH 2/2] Use async_add_executor_job instead of async_add_job (#11) --- .pre-commit-config.yaml | 2 +- custom_components/nextbike/manifest.json | 2 +- custom_components/nextbike/sensor.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da90577..76d0289 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/ambv/black - rev: stable + rev: 24.10.0 hooks: - id: black language_version: python3 diff --git a/custom_components/nextbike/manifest.json b/custom_components/nextbike/manifest.json index c15df5e..81c0ed0 100644 --- a/custom_components/nextbike/manifest.json +++ b/custom_components/nextbike/manifest.json @@ -10,5 +10,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/syssi/nextbike/issues", "requirements": [], - "version": "1.1.1" + "version": "1.2.0" } diff --git a/custom_components/nextbike/sensor.py b/custom_components/nextbike/sensor.py index ebcfa46..197945e 100644 --- a/custom_components/nextbike/sensor.py +++ b/custom_components/nextbike/sensor.py @@ -4,6 +4,7 @@ For more details about this platform, please refer to the documentation at https://github.com/syssi/nextbike """ + import asyncio import logging from datetime import timedelta @@ -146,7 +147,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= if city_id not in hass.data[PLATFORM]: city = NextbikeCity(hass, city_id) hass.data[PLATFORM][city_id] = city - hass.async_add_job(city.async_refresh) + hass.async_add_executor_job(city.async_refresh) async_track_time_interval(hass, city.async_refresh, SCAN_INTERVAL) else: city = hass.data[PLATFORM][city_id]