Moved to use a SensorEntity

This commit is contained in:
Roger Gonzalez 2023-09-23 20:44:51 -03:00
parent 6e40514a2d
commit 921274bcb2
Signed by: rogs
GPG Key ID: C7ECE9C6C36EC2E6
2 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"codeowners": ["@rogsme"], "codeowners": ["@rogsme"],
"config_flow": true, "config_flow": false,
"dependencies": [], "dependencies": [],
"documentation": "https://github.com/rogsme/homeassistant_ute", "documentation": "https://github.com/rogsme/homeassistant_ute",
"domain": "ute", "domain": "ute",

View File

@ -4,9 +4,8 @@ from typing import Callable, Optional
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
import voluptuous as vol 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.const import CONF_EMAIL, UnitOfPower
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, HomeAssistantType
from ute_wrapper.ute import UTEClient from ute_wrapper.ute import UTEClient
@ -39,7 +38,7 @@ def setup_platform(
async_add_entities(sensor, update_before_add=True) async_add_entities(sensor, update_before_add=True)
class UTESensor(Entity): class UTESensor(SensorEntity):
"""Representation of a UTE sensor.""" """Representation of a UTE sensor."""
_attr_name = "UTE Uruguay Client" _attr_name = "UTE Uruguay Client"
@ -56,4 +55,4 @@ class UTESensor(Entity):
def update(self): def update(self):
ute_data = await self.ute.get_current_usage_info() 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"]