Migrate integrations i-m to extend SensorEntity (#48213)
This commit is contained in:
parent
64bc9a8196
commit
fdf97eaca3
62 changed files with 152 additions and 157 deletions
|
@ -4,14 +4,13 @@ import logging
|
|||
import pyloopenergy
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.const import (
|
||||
CONF_UNIT_SYSTEM_IMPERIAL,
|
||||
CONF_UNIT_SYSTEM_METRIC,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -82,7 +81,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
add_entities(sensors)
|
||||
|
||||
|
||||
class LoopEnergyDevice(Entity):
|
||||
class LoopEnergySensor(SensorEntity):
|
||||
"""Implementation of an Loop Energy base sensor."""
|
||||
|
||||
def __init__(self, controller):
|
||||
|
@ -116,7 +115,7 @@ class LoopEnergyDevice(Entity):
|
|||
self.schedule_update_ha_state(True)
|
||||
|
||||
|
||||
class LoopEnergyElec(LoopEnergyDevice):
|
||||
class LoopEnergyElec(LoopEnergySensor):
|
||||
"""Implementation of an Loop Energy Electricity sensor."""
|
||||
|
||||
def __init__(self, controller):
|
||||
|
@ -133,7 +132,7 @@ class LoopEnergyElec(LoopEnergyDevice):
|
|||
self._state = round(self._controller.electricity_useage, 2)
|
||||
|
||||
|
||||
class LoopEnergyGas(LoopEnergyDevice):
|
||||
class LoopEnergyGas(LoopEnergySensor):
|
||||
"""Implementation of an Loop Energy Gas sensor."""
|
||||
|
||||
def __init__(self, controller):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue