From 921274bcb2d92d034bd78ea9f3a68693d38cb8bc Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 23 Sep 2023 20:44:51 -0300 Subject: [PATCH] Moved to use a SensorEntity --- custom_components/ute/manifest.json | 2 +- custom_components/ute/sensor.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/custom_components/ute/manifest.json b/custom_components/ute/manifest.json index bfb6cf2..149eb4c 100644 --- a/custom_components/ute/manifest.json +++ b/custom_components/ute/manifest.json @@ -1,6 +1,6 @@ { "codeowners": ["@rogsme"], - "config_flow": true, + "config_flow": false, "dependencies": [], "documentation": "https://github.com/rogsme/homeassistant_ute", "domain": "ute", diff --git a/custom_components/ute/sensor.py b/custom_components/ute/sensor.py index da23958..101f13f 100644 --- a/custom_components/ute/sensor.py +++ b/custom_components/ute/sensor.py @@ -4,9 +4,8 @@ from typing import Callable, Optional import homeassistant.helpers.config_validation as cv import voluptuous as vol -from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorDeviceClass +from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorDeviceClass, SensorEntity from homeassistant.const import CONF_EMAIL, UnitOfPower -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, HomeAssistantType from ute_wrapper.ute import UTEClient @@ -39,7 +38,7 @@ def setup_platform( async_add_entities(sensor, update_before_add=True) -class UTESensor(Entity): +class UTESensor(SensorEntity): """Representation of a UTE sensor.""" _attr_name = "UTE Uruguay Client" @@ -56,4 +55,4 @@ class UTESensor(Entity): def update(self): ute_data = await self.ute.get_current_usage_info() - self._state = ute_data["data"]["power_in_watts"] + self._attr_native_value = ute_data["data"]["power_in_watts"]