GuyKh / iec-custom-component

HomeAssistant Custom Component for IEC
MIT License
131 stars 5 forks source link

unsupported operand type(s) for -: 'NoneType' and 'int' #179

Closed GuyKh closed 1 month ago

GuyKh commented 1 month ago

System Health details

NA

Checklist

Describe the issue

Failure calculating estimated usage

Reproduction steps

NA

Debug logs

2024-10-10 10:28:49.347 ERROR (MainThread) [custom_components.iec.coordinator] Unexpected error fetching Iec data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/coordinator.py", line 423, in _async_update_data
    total_kva_price, estimated_kwh_consumption = await self._estimate_bill(contract_id, device.device_number,
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/coordinator.py", line 680, in _estimate_bill
    return self._calculate_estimated_bill(device_number, future_consumption,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/iec/coordinator.py", line 693, in _calculate_estimated_bill
    future_consumption = future_consumption_info.total_import - last_meter_read
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'


### Diagnostics dump

_No response_