pawelhulek / pgnig-sensor

This sensor is gathering gas usage data from PGNIG ebok page.
MIT License
32 stars 8 forks source link

"Pamiętaj cholero, nie dziel przez zero" #38

Closed luzik closed 2 years ago

luzik commented 2 years ago

Po aktualizacji takie coś...

Error adding entities for domain sensor with platform pgnig_gas_sensor
Error while setting up pgnig_gas_sensor platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 673, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 776, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state
    if (state := self.state) is None:
  File "/config/custom_components/pgnig_gas_sensor/sensor.py", line 224, in state
    return self._state.gross_amount / self._state.wear_kwh
ZeroDivisionError: float division by zero
pawelhulek commented 2 years ago

Wersja Beta v2.3.3 została opublikowana z poprawka -

Ciekawi mnie co to byla za faktura bez gazu. Przychodzi mi na mysl tylko oddzielna faktura na odsetki za spoznione platnosci. Zakładałem ze to bedzie jakos dodawane do odczytu a tu prosze ;)

luzik commented 2 years ago

To jeszcze coś takiego

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 673, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 776, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 532, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 570, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _stringify_state
    if (state := self.state) is None:
  File "/config/custom_components/pgnig_gas_sensor/sensor.py", line 224, in state
    return self._state.gross_amount / self._state.wear
TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'