Skip to content

Commit

Permalink
remove obsolete code
Browse files Browse the repository at this point in the history
Signed-off-by: pawel.hulek <[email protected]>
  • Loading branch information
pawelhulek committed Jan 31, 2024
1 parent 2bc84a2 commit def3464
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions custom_components/pgnig_gas_sensor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit def3464

Please sign in to comment.