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

Enbridge Gas Rate Selection Leads to update failure #47

Closed ekkridon closed 5 months ago

ekkridon commented 5 months ago

Freshly created Enbridge pricing entry as the second entry to a Toronto Hydro entry generates the following error logs:

Listing pasted as image because HA doesn't allow copying of log seach page: image

Details pasted here:

UPDATE FAILED LOG ENTRY Logger: homeassistant.helpers.entity Source: helpers/entity.py:951 First occurred: 25 April 2024 at 12:01:01 (2560 occurrences) Last logged: 09:48:57

Update for sensor.enbridge_gas_all_natural_gas_rate fails 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.py", line 951, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1268, in async_device_update await self.async_update() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 532, in async_update await self.coordinator.async_request_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in async_request_refresh await self._debounced_refresh.async_call() File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 117, in async_call await task File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 291, in async_refresh await self._async_refresh(log_failures=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 416, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 494, in _handle_coordinator_update 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'>)

ERROR UNLOADING ENTRY Logger: homeassistant.config_entries Source: config_entries.py:724 First occurred: 25 April 2024 at 20:43:38 (2 occurrences) Last logged: 25 April 2024 at 20:44:04

Error unloading entry Enbridge Gas (All) [Natural Gas] for ontario_energy_board Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 724, in async_unload result = await component.async_unload_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ontario_energy_board/init.py", line 33, in async_unload_entry unload_ok = await hass.config_entries.async_forward_entry_unload(entry, PLATFORMS) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1930, in async_forward_entry_unload if domain not in self.hass.config.components: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unhashable type: 'list'

ERROR ADDING LOG ENTRY Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:580 integration: Sensor (documentation, issues) First occurred: 25 April 2024 at 12:00:31 (2 occurrences) Last logged: 25 April 2024 at 20:43:49

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'>)

jrfernandes commented 5 months ago

Are you using the latest version (v0.4.1)? This is a know issue that was fixed in that version.

ekkridon commented 5 months ago

Confirmed fix in the latest release. Thanks!