From 0faccaafaa02a298b71a61f0f690a67559d8458f Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Sun, 24 Sep 2023 09:06:19 +0100 Subject: [PATCH] chore: Updated sensors to inherit from RestoreSensor (as recommended in docs) --- .../current_accumulative_consumption.py | 11 +++---- ...rrent_accumulative_consumption_off_peak.py | 11 +++---- .../current_accumulative_consumption_peak.py | 11 +++---- .../electricity/current_accumulative_cost.py | 11 +++---- .../current_accumulative_cost_off_peak.py | 11 +++---- .../current_accumulative_cost_peak.py | 11 +++---- .../electricity/current_consumption.py | 11 +++---- .../electricity/current_demand.py | 11 +++---- .../electricity/current_rate.py | 11 +++---- .../octopus_energy/electricity/next_rate.py | 11 +++---- .../octopus_energy/electricity/off_peak.py | 2 +- .../previous_accumulative_consumption.py | 11 +++---- ...vious_accumulative_consumption_off_peak.py | 11 +++---- .../previous_accumulative_consumption_peak.py | 11 +++---- .../electricity/previous_accumulative_cost.py | 11 +++---- .../previous_accumulative_cost_off_peak.py | 11 +++---- .../previous_accumulative_cost_override.py | 11 +++---- ...vious_accumulative_cost_override_tariff.py | 31 +++---------------- .../previous_accumulative_cost_peak.py | 10 +++--- .../electricity/previous_rate.py | 11 +++---- .../electricity/standing_charge.py | 9 +++--- custom_components/octopus_energy/gas/base.py | 7 +---- .../gas/current_accumulative_consumption.py | 9 +++--- .../gas/current_accumulative_cost.py | 9 +++--- .../octopus_energy/gas/current_consumption.py | 9 +++--- .../octopus_energy/gas/current_rate.py | 9 +++--- .../octopus_energy/gas/next_rate.py | 9 +++--- .../gas/previous_accumulative_consumption.py | 9 +++--- .../previous_accumulative_consumption_kwh.py | 9 +++--- .../gas/previous_accumulative_cost.py | 9 +++--- .../previous_accumulative_cost_override.py | 9 +++--- ...vious_accumulative_cost_override_tariff.py | 27 +++------------- .../octopus_energy/gas/previous_rate.py | 9 +++--- .../octopus_energy/gas/standing_charge.py | 9 +++--- .../octopus_energy/intelligent/bump_charge.py | 2 +- .../intelligent/charge_limit.py | 2 +- .../octopus_energy/intelligent/dispatching.py | 2 +- .../octopus_energy/intelligent/ready_time.py | 2 +- .../intelligent/smart_charge.py | 2 +- .../octopus_energy/saving_sessions/points.py | 9 +++--- .../saving_sessions/saving_sessions.py | 2 +- .../target_rates/target_rate.py | 2 +- 42 files changed, 171 insertions(+), 224 deletions(-) diff --git a/custom_components/octopus_energy/electricity/current_accumulative_consumption.py b/custom_components/octopus_energy/electricity/current_accumulative_consumption.py index fe978508..5523747e 100644 --- a/custom_components/octopus_energy/electricity/current_accumulative_consumption.py +++ b/custom_components/octopus_energy/electricity/current_accumulative_consumption.py @@ -6,11 +6,10 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR ) @@ -21,12 +20,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeElectricityConsumption(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentAccumulativeElectricityConsumption(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current accumulative electricity consumption.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_accumulative_consumption_off_peak.py b/custom_components/octopus_energy/electricity/current_accumulative_consumption_off_peak.py index 39833a71..17a0b11d 100644 --- a/custom_components/octopus_energy/electricity/current_accumulative_consumption_off_peak.py +++ b/custom_components/octopus_energy/electricity/current_accumulative_consumption_off_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR @@ -25,12 +24,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeElectricityConsumptionOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentAccumulativeElectricityConsumptionOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current days accumulative electricity reading during off peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_accumulative_consumption_peak.py b/custom_components/octopus_energy/electricity/current_accumulative_consumption_peak.py index 5425cf2f..7f048475 100644 --- a/custom_components/octopus_energy/electricity/current_accumulative_consumption_peak.py +++ b/custom_components/octopus_energy/electricity/current_accumulative_consumption_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR ) @@ -24,12 +23,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeElectricityConsumptionPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentAccumulativeElectricityConsumptionPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current days accumulative electricity reading during peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_accumulative_cost.py b/custom_components/octopus_energy/electricity/current_accumulative_cost.py index b95185aa..d8b314fe 100644 --- a/custom_components/octopus_energy/electricity/current_accumulative_cost.py +++ b/custom_components/octopus_energy/electricity/current_accumulative_cost.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, ) @@ -20,12 +19,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeElectricityCost(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentAccumulativeElectricityCost(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current days accumulative electricity cost.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/electricity/current_accumulative_cost_off_peak.py b/custom_components/octopus_energy/electricity/current_accumulative_cost_off_peak.py index 6c65bcb2..7ad16cc1 100644 --- a/custom_components/octopus_energy/electricity/current_accumulative_cost_off_peak.py +++ b/custom_components/octopus_energy/electricity/current_accumulative_cost_off_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, ) @@ -20,12 +19,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeElectricityCostOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentAccumulativeElectricityCostOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current days accumulative electricity cost during off peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_accumulative_cost_peak.py b/custom_components/octopus_energy/electricity/current_accumulative_cost_peak.py index c1c38ccc..1e43423f 100644 --- a/custom_components/octopus_energy/electricity/current_accumulative_cost_peak.py +++ b/custom_components/octopus_energy/electricity/current_accumulative_cost_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, ) @@ -20,12 +19,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeElectricityCostPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentAccumulativeElectricityCostPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current days accumulative electricity cost during peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_consumption.py b/custom_components/octopus_energy/electricity/current_consumption.py index 6cc827a4..dd96fb18 100644 --- a/custom_components/octopus_energy/electricity/current_consumption.py +++ b/custom_components/octopus_energy/electricity/current_consumption.py @@ -7,11 +7,10 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR ) @@ -22,12 +21,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentElectricityConsumption(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentElectricityConsumption(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current electricity consumption.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_demand.py b/custom_components/octopus_energy/electricity/current_demand.py index aece4c01..7aa8c4f6 100644 --- a/custom_components/octopus_energy/electricity/current_demand.py +++ b/custom_components/octopus_energy/electricity/current_demand.py @@ -7,22 +7,21 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from .base import (OctopusEnergyElectricitySensor) _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentElectricityDemand(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyCurrentElectricityDemand(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current electricity demand.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/current_rate.py b/custom_components/octopus_energy/electricity/current_rate.py index 3dd672df..fe1e249e 100644 --- a/custom_components/octopus_energy/electricity/current_rate.py +++ b/custom_components/octopus_energy/electricity/current_rate.py @@ -8,11 +8,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from .base import (OctopusEnergyElectricitySensor) @@ -20,13 +19,13 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyElectricityCurrentRate(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyElectricityCurrentRate(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current rate.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point, tariff_code, electricity_price_cap): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/next_rate.py b/custom_components/octopus_energy/electricity/next_rate.py index 92788021..ecae486c 100644 --- a/custom_components/octopus_energy/electricity/next_rate.py +++ b/custom_components/octopus_energy/electricity/next_rate.py @@ -8,24 +8,23 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from .base import (OctopusEnergyElectricitySensor) from ..utils.rate_information import (get_next_rate_information) _LOGGER = logging.getLogger(__name__) -class OctopusEnergyElectricityNextRate(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyElectricityNextRate(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the next rate.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/off_peak.py b/custom_components/octopus_energy/electricity/off_peak.py index de0afd6d..c1f98276 100644 --- a/custom_components/octopus_energy/electricity/off_peak.py +++ b/custom_components/octopus_energy/electricity/off_peak.py @@ -25,7 +25,7 @@ class OctopusEnergyElectricityOffPeak(CoordinatorEntity, OctopusEnergyElectricit def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_consumption.py b/custom_components/octopus_energy/electricity/previous_accumulative_consumption.py index 1d5234bf..926c673c 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_consumption.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_consumption.py @@ -9,11 +9,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR ) @@ -26,12 +25,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityConsumption(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityConsumption(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity reading.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_consumption_off_peak.py b/custom_components/octopus_energy/electricity/previous_accumulative_consumption_off_peak.py index f83fbd58..b4063645 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_consumption_off_peak.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_consumption_off_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR ) @@ -24,12 +23,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityConsumptionOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityConsumptionOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity reading during off peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_consumption_peak.py b/custom_components/octopus_energy/electricity/previous_accumulative_consumption_peak.py index 6c9a6f10..45a1d5ef 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_consumption_peak.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_consumption_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.const import ( ENERGY_KILO_WATT_HOUR ) @@ -24,12 +23,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityConsumptionPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityConsumptionPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity reading during peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_cost.py b/custom_components/octopus_energy/electricity/previous_accumulative_cost.py index 23d71461..677a801a 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_cost.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_cost.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, ) @@ -22,12 +21,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityCost(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityCost(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity cost.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_cost_off_peak.py b/custom_components/octopus_energy/electricity/previous_accumulative_cost_off_peak.py index 99f6bee6..21a4a088 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_cost_off_peak.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_cost_off_peak.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, ) @@ -20,12 +19,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityCostOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityCostOffPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity cost during off peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py b/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py index ece90beb..4aec454c 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_cost_override.py @@ -7,11 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, @@ -27,12 +26,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityCostOverride(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityCostOverride(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity cost for a different tariff.""" def __init__(self, hass: HomeAssistant, coordinator, client: OctopusEnergyApiClient, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_cost_override_tariff.py b/custom_components/octopus_energy/electricity/previous_accumulative_cost_override_tariff.py index 9c849ea3..e9cd7002 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_cost_override_tariff.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_cost_override_tariff.py @@ -16,32 +16,18 @@ from ..api_client import OctopusEnergyApiClient +from .base import (OctopusEnergyElectricitySensor) + _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityCostTariffOverride(TextEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityCostTariffOverride(OctopusEnergyElectricitySensor, TextEntity, RestoreEntity): """Sensor for the tariff for the previous days accumulative electricity cost looking at a different tariff.""" _attr_pattern = REGEX_TARIFF_PARTS def __init__(self, hass: HomeAssistant, client: OctopusEnergyApiClient, tariff_code, meter, point): """Init sensor.""" - - self._point = point - self._meter = meter - - self._mpan = point["mpan"] - self._serial_number = meter["serial_number"] - self._is_export = meter["is_export"] - self._is_smart_meter = meter["is_smart_meter"] - self._export_id_addition = "_export" if self._is_export == True else "" - self._export_name_addition = " Export" if self._is_export == True else "" - - self._attributes = { - "mpan": self._mpan, - "serial_number": self._serial_number, - "is_export": self._is_export, - "is_smart_meter": self._is_smart_meter - } + OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self.entity_id = generate_entity_id("text.{}", self.unique_id, hass=hass) @@ -50,15 +36,6 @@ def __init__(self, hass: HomeAssistant, client: OctopusEnergyApiClient, tariff_c self._client = client self._tariff_code = tariff_code self._attr_native_value = tariff_code - - self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, f"electricity_{self._serial_number}_{self._mpan}")}, - name=f"Electricity Meter{self._export_name_addition}", - connections=set(), - manufacturer=self._meter["manufacturer"], - model=self._meter["model"], - sw_version=self._meter["firmware"] - ) @property def entity_registry_enabled_default(self) -> bool: diff --git a/custom_components/octopus_energy/electricity/previous_accumulative_cost_peak.py b/custom_components/octopus_energy/electricity/previous_accumulative_cost_peak.py index ff88ed4f..17b79155 100644 --- a/custom_components/octopus_energy/electricity/previous_accumulative_cost_peak.py +++ b/custom_components/octopus_energy/electricity/previous_accumulative_cost_peak.py @@ -7,10 +7,10 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass,SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from . import ( calculate_electricity_consumption_and_cost, ) @@ -19,12 +19,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeElectricityCostPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeElectricityCostPeak(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous days accumulative electricity cost during peak hours.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/electricity/previous_rate.py b/custom_components/octopus_energy/electricity/previous_rate.py index c9694384..750cc33a 100644 --- a/custom_components/octopus_energy/electricity/previous_rate.py +++ b/custom_components/octopus_energy/electricity/previous_rate.py @@ -8,24 +8,23 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, + SensorStateClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from .base import (OctopusEnergyElectricitySensor) from ..utils.rate_information import (get_previous_rate_information) _LOGGER = logging.getLogger(__name__) -class OctopusEnergyElectricityPreviousRate(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyElectricityPreviousRate(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the previous rate.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/electricity/standing_charge.py b/custom_components/octopus_energy/electricity/standing_charge.py index f074a167..0149cdbd 100644 --- a/custom_components/octopus_energy/electricity/standing_charge.py +++ b/custom_components/octopus_energy/electricity/standing_charge.py @@ -3,10 +3,9 @@ from homeassistant.core import HomeAssistant from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorEntity, + RestoreSensor, + SensorDeviceClass, ) -from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, ) @@ -15,12 +14,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyElectricityCurrentStandingCharge(CoordinatorEntity, OctopusEnergyElectricitySensor, SensorEntity, RestoreEntity): +class OctopusEnergyElectricityCurrentStandingCharge(CoordinatorEntity, OctopusEnergyElectricitySensor, RestoreSensor): """Sensor for displaying the current standing charge.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyElectricitySensor.__init__(self, hass, meter, point) self._tariff_code = tariff_code diff --git a/custom_components/octopus_energy/gas/base.py b/custom_components/octopus_energy/gas/base.py index 7430d6a6..5466fdf0 100644 --- a/custom_components/octopus_energy/gas/base.py +++ b/custom_components/octopus_energy/gas/base.py @@ -1,17 +1,12 @@ from homeassistant.core import HomeAssistant -from homeassistant.components.sensor import ( - SensorEntity, -) -from homeassistant.helpers.restore_state import RestoreEntity - from homeassistant.helpers.entity import generate_entity_id, DeviceInfo from ..const import ( DOMAIN, ) -class OctopusEnergyGasSensor(SensorEntity, RestoreEntity): +class OctopusEnergyGasSensor: def __init__(self, hass: HomeAssistant, meter, point): """Init sensor""" self._point = point diff --git a/custom_components/octopus_energy/gas/current_accumulative_consumption.py b/custom_components/octopus_energy/gas/current_accumulative_consumption.py index 6c6ebd25..99df3d1e 100644 --- a/custom_components/octopus_energy/gas/current_accumulative_consumption.py +++ b/custom_components/octopus_energy/gas/current_accumulative_consumption.py @@ -6,8 +6,9 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from homeassistant.const import ( ENERGY_KILO_WATT_HOUR @@ -19,12 +20,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeGasConsumption(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyCurrentAccumulativeGasConsumption(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the current accumulative gas consumption.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point, calorific_value): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/gas/current_accumulative_cost.py b/custom_components/octopus_energy/gas/current_accumulative_cost.py index 788e1bf7..7852bd03 100644 --- a/custom_components/octopus_energy/gas/current_accumulative_cost.py +++ b/custom_components/octopus_energy/gas/current_accumulative_cost.py @@ -7,8 +7,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from . import ( calculate_gas_consumption_and_cost, @@ -20,12 +21,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentAccumulativeGasCost(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyCurrentAccumulativeGasCost(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the current days accumulative gas cost.""" def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, standing_charge_coordinator, tariff_code, meter, point, calorific_value): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/gas/current_consumption.py b/custom_components/octopus_energy/gas/current_consumption.py index 9c71344d..b2c4b9e9 100644 --- a/custom_components/octopus_energy/gas/current_consumption.py +++ b/custom_components/octopus_energy/gas/current_consumption.py @@ -7,8 +7,9 @@ CoordinatorEntity ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from homeassistant.const import ( ENERGY_KILO_WATT_HOUR @@ -20,12 +21,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyCurrentGasConsumption(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyCurrentGasConsumption(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the current gas consumption.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/gas/current_rate.py b/custom_components/octopus_energy/gas/current_rate.py index 462bf94c..9014618c 100644 --- a/custom_components/octopus_energy/gas/current_rate.py +++ b/custom_components/octopus_energy/gas/current_rate.py @@ -8,8 +8,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from .base import (OctopusEnergyGasSensor) @@ -17,12 +18,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyGasCurrentRate(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyGasCurrentRate(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the current rate.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point, gas_price_cap): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._tariff_code = tariff_code diff --git a/custom_components/octopus_energy/gas/next_rate.py b/custom_components/octopus_energy/gas/next_rate.py index 6a2d21be..f3b70433 100644 --- a/custom_components/octopus_energy/gas/next_rate.py +++ b/custom_components/octopus_energy/gas/next_rate.py @@ -8,8 +8,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from .base import (OctopusEnergyGasSensor) @@ -17,12 +18,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyGasNextRate(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyGasNextRate(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the next rate.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/gas/previous_accumulative_consumption.py b/custom_components/octopus_energy/gas/previous_accumulative_consumption.py index d33828a2..91825347 100644 --- a/custom_components/octopus_energy/gas/previous_accumulative_consumption.py +++ b/custom_components/octopus_energy/gas/previous_accumulative_consumption.py @@ -7,8 +7,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from homeassistant.const import ( VOLUME_CUBIC_METERS @@ -22,12 +23,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeGasConsumption(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyPreviousAccumulativeGasConsumption(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the previous days accumulative gas reading.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point, calorific_value): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/gas/previous_accumulative_consumption_kwh.py b/custom_components/octopus_energy/gas/previous_accumulative_consumption_kwh.py index 6c6d037f..978ac0ed 100644 --- a/custom_components/octopus_energy/gas/previous_accumulative_consumption_kwh.py +++ b/custom_components/octopus_energy/gas/previous_accumulative_consumption_kwh.py @@ -7,8 +7,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from homeassistant.const import ( ENERGY_KILO_WATT_HOUR @@ -22,12 +23,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeGasConsumptionKwh(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyPreviousAccumulativeGasConsumptionKwh(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the previous days accumulative gas consumption in kwh.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point, calorific_value): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/gas/previous_accumulative_cost.py b/custom_components/octopus_energy/gas/previous_accumulative_cost.py index 96c74a73..d076c70c 100644 --- a/custom_components/octopus_energy/gas/previous_accumulative_cost.py +++ b/custom_components/octopus_energy/gas/previous_accumulative_cost.py @@ -7,8 +7,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from . import ( calculate_gas_consumption_and_cost, @@ -20,12 +21,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeGasCost(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyPreviousAccumulativeGasCost(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the previous days accumulative gas cost.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point, calorific_value): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py b/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py index 5c4bf079..c9ead851 100644 --- a/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py +++ b/custom_components/octopus_energy/gas/previous_accumulative_cost_override.py @@ -7,8 +7,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from . import ( @@ -24,12 +25,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeGasCostOverride(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyPreviousAccumulativeGasCostOverride(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the previous days accumulative gas cost for a different tariff.""" def __init__(self, hass: HomeAssistant, coordinator, client: OctopusEnergyApiClient, tariff_code, meter, point, calorific_value): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._hass = hass diff --git a/custom_components/octopus_energy/gas/previous_accumulative_cost_override_tariff.py b/custom_components/octopus_energy/gas/previous_accumulative_cost_override_tariff.py index ff5c276f..f20614f4 100644 --- a/custom_components/octopus_energy/gas/previous_accumulative_cost_override_tariff.py +++ b/custom_components/octopus_energy/gas/previous_accumulative_cost_override_tariff.py @@ -16,43 +16,26 @@ from ..api_client import OctopusEnergyApiClient +from .base import (OctopusEnergyGasSensor) + _LOGGER = logging.getLogger(__name__) -class OctopusEnergyPreviousAccumulativeGasCostTariffOverride(TextEntity, RestoreEntity): +class OctopusEnergyPreviousAccumulativeGasCostTariffOverride(OctopusEnergyGasSensor, TextEntity, RestoreEntity): """Sensor for the tariff for the previous days accumulative gas cost looking at a different tariff.""" _attr_pattern = REGEX_TARIFF_PARTS def __init__(self, hass: HomeAssistant, client: OctopusEnergyApiClient, tariff_code, meter, point): """Init sensor.""" - - self._point = point - self._meter = meter - - self._mprn = point["mprn"] - self._serial_number = meter["serial_number"] + OctopusEnergyGasSensor.__init__(self, hass, meter, point) - self._attributes = { - "mprn": self._mprn, - "serial_number": self._serial_number - } - - self.entity_id = generate_entity_id("sensor.{}", self.unique_id, hass=hass) + self.entity_id = generate_entity_id("text.{}", self.unique_id, hass=hass) self._hass = hass self._client = client self._tariff_code = tariff_code self._attr_native_value = tariff_code - - self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, f"gas_{self._serial_number}_{self._mprn}")}, - name="Gas Meter", - connections=set(), - manufacturer=self._meter["manufacturer"], - model=self._meter["model"], - sw_version=self._meter["firmware"] - ) @property def entity_registry_enabled_default(self) -> bool: diff --git a/custom_components/octopus_energy/gas/previous_rate.py b/custom_components/octopus_energy/gas/previous_rate.py index 53721a32..ec8de9b1 100644 --- a/custom_components/octopus_energy/gas/previous_rate.py +++ b/custom_components/octopus_energy/gas/previous_rate.py @@ -8,8 +8,9 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from .base import (OctopusEnergyGasSensor) @@ -17,12 +18,12 @@ _LOGGER = logging.getLogger(__name__) -class OctopusEnergyGasPreviousRate(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyGasPreviousRate(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the previous rate.""" def __init__(self, hass: HomeAssistant, coordinator, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._state = None diff --git a/custom_components/octopus_energy/gas/standing_charge.py b/custom_components/octopus_energy/gas/standing_charge.py index 88e077d5..081dae8e 100644 --- a/custom_components/octopus_energy/gas/standing_charge.py +++ b/custom_components/octopus_energy/gas/standing_charge.py @@ -6,20 +6,21 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorDeviceClass, - SensorStateClass + RestoreSensor, + SensorDeviceClass, + SensorStateClass ) from .base import (OctopusEnergyGasSensor) _LOGGER = logging.getLogger(__name__) -class OctopusEnergyGasCurrentStandingCharge(CoordinatorEntity, OctopusEnergyGasSensor): +class OctopusEnergyGasCurrentStandingCharge(CoordinatorEntity, OctopusEnergyGasSensor, RestoreSensor): """Sensor for displaying the current standing charge.""" def __init__(self, hass: HomeAssistant, coordinator, tariff_code, meter, point): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyGasSensor.__init__(self, hass, meter, point) self._tariff_code = tariff_code diff --git a/custom_components/octopus_energy/intelligent/bump_charge.py b/custom_components/octopus_energy/intelligent/bump_charge.py index 41000109..57f18494 100644 --- a/custom_components/octopus_energy/intelligent/bump_charge.py +++ b/custom_components/octopus_energy/intelligent/bump_charge.py @@ -21,7 +21,7 @@ class OctopusEnergyIntelligentBumpCharge(CoordinatorEntity, SwitchEntity, Octopu def __init__(self, hass: HomeAssistant, coordinator, client: OctopusEnergyApiClient, device, account_id: str): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyIntelligentSensor.__init__(self, device) self._state = False diff --git a/custom_components/octopus_energy/intelligent/charge_limit.py b/custom_components/octopus_energy/intelligent/charge_limit.py index 18c90410..1475f934 100644 --- a/custom_components/octopus_energy/intelligent/charge_limit.py +++ b/custom_components/octopus_energy/intelligent/charge_limit.py @@ -22,7 +22,7 @@ class OctopusEnergyIntelligentChargeLimit(CoordinatorEntity, RestoreNumber, Octo def __init__(self, hass: HomeAssistant, coordinator, client: OctopusEnergyApiClient, device, account_id: str): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyIntelligentSensor.__init__(self, device) self._state = None diff --git a/custom_components/octopus_energy/intelligent/dispatching.py b/custom_components/octopus_energy/intelligent/dispatching.py index 6e4f2b19..62c934e9 100644 --- a/custom_components/octopus_energy/intelligent/dispatching.py +++ b/custom_components/octopus_energy/intelligent/dispatching.py @@ -29,7 +29,7 @@ class OctopusEnergyIntelligentDispatching(CoordinatorEntity, BinarySensorEntity, def __init__(self, hass: HomeAssistant, coordinator, rates_coordinator, mpan, device): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyIntelligentSensor.__init__(self, device) self._rates_coordinator = rates_coordinator diff --git a/custom_components/octopus_energy/intelligent/ready_time.py b/custom_components/octopus_energy/intelligent/ready_time.py index 99983b12..c68a28eb 100644 --- a/custom_components/octopus_energy/intelligent/ready_time.py +++ b/custom_components/octopus_energy/intelligent/ready_time.py @@ -21,7 +21,7 @@ class OctopusEnergyIntelligentReadyTime(CoordinatorEntity, TimeEntity, OctopusEn def __init__(self, hass: HomeAssistant, coordinator, client: OctopusEnergyApiClient, device, account_id: str): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyIntelligentSensor.__init__(self, device) self._state = time() diff --git a/custom_components/octopus_energy/intelligent/smart_charge.py b/custom_components/octopus_energy/intelligent/smart_charge.py index 28b87d04..cd7e9be0 100644 --- a/custom_components/octopus_energy/intelligent/smart_charge.py +++ b/custom_components/octopus_energy/intelligent/smart_charge.py @@ -20,7 +20,7 @@ class OctopusEnergyIntelligentSmartCharge(CoordinatorEntity, SwitchEntity, Octop def __init__(self, hass: HomeAssistant, coordinator, client: OctopusEnergyApiClient, device, account_id: str): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) OctopusEnergyIntelligentSensor.__init__(self, device) self._state = False diff --git a/custom_components/octopus_energy/saving_sessions/points.py b/custom_components/octopus_energy/saving_sessions/points.py index 09b81d6b..43c625c3 100644 --- a/custom_components/octopus_energy/saving_sessions/points.py +++ b/custom_components/octopus_energy/saving_sessions/points.py @@ -7,20 +7,19 @@ CoordinatorEntity, ) from homeassistant.components.sensor import ( - SensorEntity, - SensorStateClass + RestoreSensor, + SensorStateClass ) -from homeassistant.helpers.restore_state import RestoreEntity _LOGGER = logging.getLogger(__name__) -class OctopusEnergySavingSessionPoints(CoordinatorEntity, SensorEntity, RestoreEntity): +class OctopusEnergySavingSessionPoints(CoordinatorEntity, RestoreSensor): """Sensor for determining saving session points""" def __init__(self, hass: HomeAssistant, coordinator): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) self._state = None self._attributes = {} diff --git a/custom_components/octopus_energy/saving_sessions/saving_sessions.py b/custom_components/octopus_energy/saving_sessions/saving_sessions.py index c73dc819..ba7fd387 100644 --- a/custom_components/octopus_energy/saving_sessions/saving_sessions.py +++ b/custom_components/octopus_energy/saving_sessions/saving_sessions.py @@ -25,7 +25,7 @@ class OctopusEnergySavingSessions(CoordinatorEntity, BinarySensorEntity, Restore def __init__(self, hass: HomeAssistant, coordinator): """Init sensor.""" - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) self._state = None self._events = [] diff --git a/custom_components/octopus_energy/target_rates/target_rate.py b/custom_components/octopus_energy/target_rates/target_rate.py index e355f774..0766cad6 100644 --- a/custom_components/octopus_energy/target_rates/target_rate.py +++ b/custom_components/octopus_energy/target_rates/target_rate.py @@ -48,7 +48,7 @@ class OctopusEnergyTargetRate(CoordinatorEntity, BinarySensorEntity, RestoreEnti def __init__(self, hass: HomeAssistant, coordinator, config, is_export): """Init sensor.""" # Pass coordinator to base class - super().__init__(coordinator) + CoordinatorEntity.__init__(self, coordinator) self._state = None self._config = config