From def3464b8fa231c35fc9e17478ce54d74f9d9264 Mon Sep 17 00:00:00 2001 From: "pawel.hulek" Date: Wed, 31 Jan 2024 05:02:59 +0100 Subject: [PATCH] remove obsolete code Signed-off-by: pawel.hulek --- custom_components/pgnig_gas_sensor/sensor.py | 53 -------------------- 1 file changed, 53 deletions(-) diff --git a/custom_components/pgnig_gas_sensor/sensor.py b/custom_components/pgnig_gas_sensor/sensor.py index 5ef7a4c..478fbd2 100644 --- a/custom_components/pgnig_gas_sensor/sensor.py +++ b/custom_components/pgnig_gas_sensor/sensor.py @@ -267,56 +267,3 @@ def upcoming_payment_for_meter(x: InvoicesList): None, None, None, None, None, None, None, None, None)) - - -class PgnigKwhSensor(SensorEntity): - def __init__(self, hass, api: PgnigApi, meter_id: string, id_local: int) -> None: - self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR - self._attr_device_class = SensorDeviceClass.GAS - self._attr_state_class = SensorStateClass.TOTAL_INCREASING - self._state: MeterReading | None = None - self.hass = hass - self.api = api - self.meter_id = meter_id - self.id_local = id_local - self.entity_name = "PGNIG Gas KwH Sensor " + meter_id + " " + str(id_local) - - @property - def unique_id(self) -> str | None: - return "pgnig_kwh_sensor" + self.meter_id + "_" + str(self.id_local) - - @property - def device_info(self): - return { - "identifiers": {("pgnig_gas_sensor", self.meter_id)}, - "name": f"PGNIG GAS METER ID {self.meter_id}", - "manufacturer": "PGNIG", - "model": self.meter_id, - "via_device": None, - } - - @property - def name(self) -> str: - return self.entity_name - - @property - def state(self): - if self._state is None: - return None - return self._state.value - - @property - def extra_state_attributes(self): - attrs = dict() - if self._state is not None: - attrs["wear"] = self._state.wear - attrs["wear_unit_of_measurment"] = UnitOfVolume.CUBIC_METERS - return attrs - - async def async_update(self): - latest_meter_reading: MeterReading = await self.hass.async_add_executor_job(self.latestMeterReading) - self._state = latest_meter_reading - - def latestMeterReading(self): - return max(self.api.readingForMeter(self.meter_id).meter_readings, - key=lambda z: z.reading_date_utc)