Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems to be broken on HA 2024.1 #21

Open
mariwing opened this issue Jan 4, 2024 · 18 comments
Open

Seems to be broken on HA 2024.1 #21

mariwing opened this issue Jan 4, 2024 · 18 comments

Comments

@mariwing
Copy link

mariwing commented Jan 4, 2024

Hi!

After upgrading to 2024.1 the Elvia integration stopped working. I restored a backup (to version 2023.12.4) and it started working again.

Unfortunately I did not keep the logs from 2024.1, but if you want me to I can reinstall that version and get the error messages in the log for you.

@audun-v
Copy link

audun-v commented Jan 4, 2024

Same problem for me. This is the error from the logs.

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:360
Integration: Sensor (documentation, issues)
First occurred: 1:16:56 PM (1 occurrences)
Last logged: 1:16:56 PM

Error while setting up elvia platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/elvia/sensor.py", line 71, in async_setup_entry
    ElviaMaxHourAverageSensor(coordinator, True),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/elvia/sensor.py", line 156, in __init__
    super().__init__(coordinator, description, "elvia")
  File "/config/custom_components/elvia/sensor.py", line 97, in __init__
    description.key = f"{key_prefix}_{description.key}"
    ^^^^^^^^^^^^^^^
  File "<string>", line 4, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field 'key'

@Beerling
Copy link

Beerling commented Jan 4, 2024

I have the same issue, and also the same log entry as @audun-v

@hillmar
Copy link

hillmar commented Jan 5, 2024

Same issue on my install, after updating to 2024.1

@magnushegge
Copy link

For me the integration stopped working ond january 4th on 22:55. I did not upgrade HA core to 2024.1 until january 5th.
I get the same log message as above. All entities under the elvia integration are "Unavailable".

@grolub
Copy link

grolub commented Jan 9, 2024

Same issue after update to 2024.1

@magne74
Copy link

magne74 commented Jan 13, 2024

Same here…

@breiviar
Copy link

Same here...

@mariwing
Copy link
Author

This seems to be related to this: https://developers.home-assistant.io/blog/2023/12/11/entity-description-changes/

I am no Python developer and the Home Assistant code seems very confusing to me. But by changing line 96 and the following lines in the initialize block in sensor.py to this, the integration again works on Home Assistant 2024.1.3.

    """Initialize."""
    super().__init__(coordinator)
    self.coordinator = coordinator
    self.entity_description = description
    self.attribute = self.entity_description.key.replace(f"{key_prefix}_", "")
    self._attr_unique_id = f"{key_prefix}_{description.key}"
    self._attr_device_info = coordinator._attr_device_info
    self.update_from_data()`

@breiviar
Copy link

Thank you - works like a charm!

@magne74
Copy link

magne74 commented Jan 16, 2024

And how am I doing that @mariwing ?

@tordenflesk
Copy link

tordenflesk commented Jan 22, 2024

And how am I doing that @mariwing ?

Delete the follwing from /custom_components/elvia/sensor.py (Line 97):

    description.key = f"{key_prefix}_{description.key}"

@magne74
Copy link

magne74 commented Jan 22, 2024 via email

@magnushegge
Copy link

magnushegge commented Jan 24, 2024

Deleting (or commenting out with #) line 97 worked for me.
After a restart of HA, the integration provided values again.

Unfortunately, it created all new entities, so the Elvia device now has all the previous entities with an "unavailable" state and new entities with _2 appended to the entity ID and working values.

@mariwing
Copy link
Author

To avoid duplicates, use the line

self._attr_unique_id = f"{key_prefix}_{description.key}"

as I mentioned. This was previously set from the property that was on line 97 (?) that cause the original bug. Since that property is no longer set - the unique id should be set from the values previously used to set the property.

@mabahj
Copy link

mabahj commented Feb 8, 2024

(Original question removed: I see that you have described the full change further up. Thanks!)

@SumMarius
Copy link

Solved it for me! Thank you very much.

andreabl added a commit to andreabl/ha-elvia that referenced this issue Feb 19, 2024
andreabl added a commit to andreabl/ha-elvia that referenced this issue Feb 19, 2024
@magne74
Copy link

magne74 commented Jun 2, 2024

Maybe a stupid question but why is this not fixed yet? I have a new installation and had to do the same tweaks in the sensor.py file.

@mariwing
Copy link
Author

mariwing commented Jun 3, 2024

Probably because the creator has abandoned this project unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests