jrfernandes / ontario_energy_board

Home Assistant component that installs a sensor with the current energy rate for Ontario energy companies
MIT License
44 stars 11 forks source link

Gas Supplier Rates not showing under 0.4.0 #45

Closed kwkid closed 5 months ago

kwkid commented 5 months ago

Updated to version 0.4.0 and it's working fine with electricity provider sensor.enova_power_corp_waterloo_north_rate_zone_residential_electricity_rate under Home Assistant Core 2024.4.3.

I configured the integration to use Gas Provider Enbridge Gas (All) [NaturalGas] which it accepted successfully and created a sensor sensor.enbridge_gas_all_natural_gas_rate for it... upon restarting and rebooting HA...when you go into Developer Tools -> States and look for sensor.enbridge_gas_all_natural_gas_rate i see under State unavailable and no attributes while the sensor.enova_power_corp_waterloo_north_rate_zone_residential_electricity_rate show current rate and attribute.... perhaps i'm missing something...

Screenshot Enbridge

jrfernandes commented 5 months ago

@N3rdP1um23 - I tried this locally today and it's not working for me either. From the log:

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:580
integration: Sensor (documentation, issues)
First occurred: 8:02:37 PM (1 occurrences)
Last logged: 8:02:37 PM

Error adding entity sensor.enbridge_gas_all_natural_gas_rate for domain sensor with platform ontario_energy_board
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 668, in state
    numerical_value = float(value)  # type:ignore[arg-type]
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'no_peak'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 580, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 890, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1334, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 670, in state
    raise ValueError(
ValueError: Sensor sensor.enbridge_gas_all_natural_gas_rate has device class 'monetary', state class 'None' unit 'CA ¢/m³' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'no_peak' (<class 'str'>)
N3rdP1um23 commented 5 months ago

Hey! Apologies about that, PR #46 should help fix this issue 😃