Danielhiversen / home_assistant_tibber_data

Display Tibber data sensors.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail to load with HA 2024.1.3

newlund opened this issue · comments

Upgraded from HA 2024.1.2 to HA 2024.1.3 and now tibber_data fail to load with the following errors:

`Logger: homeassistant.loader
Source: loader.py:842
First occurred: 09:46:46 (2 occurrences)
Last logged: 09:46:46

Unexpected exception importing platform custom_components.tibber_data.sensor
Unexpected exception importing platform custom_components.tibber_data.binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 842, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 859, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/config/custom_components/tibber_data/sensor.py", line 61, in
class TibberDataSensor(SensorEntity, CoordinatorEntity["TibberDataCoordinator"]):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 408, in init
wrap_attr(cls, property_name)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 380, in wrap_attr
raise TypeError(f"Can't override {attr_name} in subclass")
TypeError: Can't override _attr_name in subclass`

`Logger: homeassistant.setup
Source: setup.py:403
First occurred: 09:46:46 (2 occurrences)
Last logged: 09:46:46

Unable to prepare setup for platform 'tibber_data.sensor': Platform not found (Exception importing custom_components.tibber_data.sensor).
Unable to prepare setup for platform 'tibber_data.binary_sensor': Platform not found (Exception importing custom_components.tibber_data.binary_sensor).`

I removed the override and set the _attr_name in the init function instead and have a working integration. I suppose I could make a pull request on this, but I have no spare time. Sorry about that.

In binary_sensor.py
`def init(self, coordinator, entity_description):
"""Initialize the sensor."""
super().init(coordinator=coordinator)
self.entity_description = entity_description
self.attr_unique_id = (
f"{coordinator.tibber_home.home_id}
{entity_description.key}"
)

    self._attr_name = f"{self.entity_description.name} {self.coordinator.tibber_home.address1}"

#@property
#def _attr_name(self):
#    """Return the name of the sensor."""
#    return f"{self.entity_description.name} {self.coordinator.tibber_home.address1}"

@callback
def _handle_coordinator_update(self) -> None:
    """Handle updated data from the coordinator."""
    self._attr_is_on = self.coordinator.data.get(self.entity_description.key)
    self.async_write_ha_state()`

In sensor.py
`def init(self, coordinator, entity_description):
"""Initialize the sensor."""
super().init(coordinator=coordinator)
self.entity_description = entity_description
self.attr_unique_id = (
f"{coordinator.tibber_home.home_id}
{entity_description.key}"
)
if entity_description.native_unit_of_measurement is None:
if entity_description.device_class == SensorDeviceClass.MONETARY:
self._attr_native_unit_of_measurement = coordinator.tibber_home.currency
else:
self._attr_native_unit_of_measurement = (
coordinator.tibber_home.price_unit
)

    _name = self.coordinator.data.get(f"{self.entity_description.key}_name")
    if _name:
        self._attr_name = _name
    else:
        self._attr_name = f"{self.entity_description.name} {self.coordinator.tibber_home.address1}"

#@property
#def _attr_name(self):
#    """Return the name of the sensor."""
#    _name = self.coordinator.data.get(f"{self.entity_description.key}_name")
#    if _name:
#        return _name
#    return f"{self.entity_description.name} {self.coordinator.tibber_home.address1}"

@callback
def _handle_coordinator_update(self) -> None:
    """Handle u`

image

image

@stigvi I've created a PR for it.

Great work!
When can we expect to see this ?
I keep getting these error on every HA restart:

Home Assistant Core
Unable to prepare setup for platform 'tibber_data.sensor': Platform not found (Exception importing custom_components.tibber_data.sensor).
January 16, 2024 at 5:41:50 PM – (ERROR) setup.py - message first occurred at January 16, 2024 at 5:41:50 PM and shows up 2 times
Unexpected exception importing platform custom_components.tibber_data.sensor
January 16, 2024 at 5:41:50 PM – (ERROR) loader.py - message first occurred at January 16, 2024 at 5:41:50 PM and shows up 2 times.

@Danielhiversen can you please trigger a new release, so an update via hacs is possible?
Thanks!

You can download it as beta.

I will make a new release when I have tested it properly myself.

You can download it as beta.

I will make a new release when I have tested it properly myself.

Even if I select beta versions, only 0.7.1 is available.......

image

You can download it as beta.
I will make a new release when I have tested it properly myself.

Even if I select beta versions, only 0.7.1 is available.......

image

Scroll to the bottom and choose 'main'

Even if I select beta versions, only 0.7.1 is available.......

Fant du beta versjonen?
Virker den?

Even if I select beta versions, only 0.7.1 is available.......

Fant du beta versjonen? Virker den?

Den ligger nederst i drop-down og heter main. Funker fjell

Jeg tror ikke jeg helt skjønner hvilken "drop-down" det her er snakk om.
Kan du kort forklare/vise hvor jeg finner denne? (eller om du har en link)

Jeg tror ikke jeg helt skjønner hvilken "drop-down" det her er snakk om. Kan du kort forklare/vise hvor jeg finner denne? (eller om du har en link)

image
The dropdown in re-download list, however now our best Mr. Iversen has released v 0.7.2 which works perfectly. Thanx Daniel!

Free at last 🌞