From 64c5006a2b6bda1be2f4d96d82e6de1ffa1e17fd Mon Sep 17 00:00:00 2001 From: marq24 Date: Tue, 3 Sep 2024 18:43:00 +0200 Subject: [PATCH] remove country from hacs.json def state -> def native_value --- custom_components/tibber_local/manifest.json | 2 +- custom_components/tibber_local/sensor.py | 28 +++++++++++--------- hacs.json | 3 --- requirements.txt | 2 ++ requirements_dev.txt | 1 + 5 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 requirements.txt create mode 100644 requirements_dev.txt diff --git a/custom_components/tibber_local/manifest.json b/custom_components/tibber_local/manifest.json index 13e2e0a..5da44ac 100644 --- a/custom_components/tibber_local/manifest.json +++ b/custom_components/tibber_local/manifest.json @@ -10,5 +10,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/marq24/ha-tibber-pulse-local/issues", "requirements": ["smllib==1.4"], - "version": "2024.8.0" + "version": "2024.9.0" } diff --git a/custom_components/tibber_local/sensor.py b/custom_components/tibber_local/sensor.py index ffed1f9..e7f3a52 100644 --- a/custom_components/tibber_local/sensor.py +++ b/custom_components/tibber_local/sensor.py @@ -3,8 +3,8 @@ from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from homeassistant.helpers.typing import StateType from homeassistant.util import slugify - from . import TibberLocalDataUpdateCoordinator, TibberLocalEntity from .const import ( DOMAIN, @@ -77,14 +77,18 @@ def __init__( self._attr_suggested_display_precision = 2 @property - def state(self): - """Return the current state.""" - value = getattr(self.coordinator.bridge, 'attr' + self.entity_description.key) - if type(value) != type(False): - try: - rounded_value = round(float(value), self._attr_suggested_display_precision) - return rounded_value - except (ValueError, TypeError): - return value - else: - return value + def native_value(self) -> StateType: + return getattr(self.coordinator.bridge, 'attr' + self.entity_description.key) + + # @property + # def state(self): + # """Return the current state.""" + # value = getattr(self.coordinator.bridge, 'attr' + self.entity_description.key) + # if type(value) != type(False): + # try: + # rounded_value = round(float(value), self._attr_suggested_display_precision) + # return rounded_value + # except (ValueError, TypeError): + # return value + # else: + # return value diff --git a/hacs.json b/hacs.json index 0456a40..08cbf3b 100644 --- a/hacs.json +++ b/hacs.json @@ -1,8 +1,5 @@ { "name": "Tibber Pulse Local", - "country": [ - "ALL" - ], "homeassistant": "2023.0.6", "hacs": "1.18.0", "render_readme": true diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..71d19cc --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +homeassistant>=2024.8.2 +smllib>=1.4 \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..e164841 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1 @@ +pytest-homeassistant-custom-component>=0.13.154 \ No newline at end of file