Cleaned up code, working now!
This commit is contained in:
parent
5c4804bfde
commit
69ee62026c
@ -34,21 +34,26 @@ def setup_platform(
|
|||||||
email = config[CONF_EMAIL]
|
email = config[CONF_EMAIL]
|
||||||
phone_number = config[CONF_PHONE_NUMBER]
|
phone_number = config[CONF_PHONE_NUMBER]
|
||||||
|
|
||||||
|
try:
|
||||||
client = UTEClient(email, phone_number)
|
client = UTEClient(email, phone_number)
|
||||||
|
except Exception:
|
||||||
|
_LOGGER.error("Could not connect to UTE")
|
||||||
|
return
|
||||||
|
|
||||||
add_entities([UTESensor(client)], True)
|
add_entities([UTESensor(client)], True)
|
||||||
|
|
||||||
|
|
||||||
class UTESensor(SensorEntity):
|
class UTESensor(SensorEntity):
|
||||||
"""Representation of a UTE sensor."""
|
"""Representation of a UTE sensor."""
|
||||||
|
|
||||||
_attr_name = "UTE Uruguay Client"
|
_attr_name = "Current power usage"
|
||||||
_attr_icon = "lightning-bolt"
|
_attr_icon = "lightning-bolt"
|
||||||
_attr_native_unit_of_measurement = UnitOfPower.WATT
|
_attr_native_unit_of_measurement = UnitOfPower.WATT
|
||||||
_attr_device_class = SensorDeviceClass.ENERGY
|
_attr_device_class = SensorDeviceClass.ENERGY
|
||||||
|
|
||||||
def __init__(self, ute: UTEClient):
|
def __init__(self, client: UTEClient):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.ute = ute
|
self.client = client
|
||||||
self._state = None
|
self._state = None
|
||||||
self._available = True
|
self._available = True
|
||||||
self._name = "Current energy usage"
|
self._name = "Current energy usage"
|
||||||
|
Reference in New Issue
Block a user