tomaae / homeassistant-truenas

TrueNAS integration for Home Assistant
Apache License 2.0
194 stars 19 forks source link

[Bug] Exception in update_controller when dispatching 'truenas-update-TrueNAS' #106

Closed pantherale0 closed 7 months ago

pantherale0 commented 1 year ago

Describe the issue

I'm not sure if this has been reported or not, but HA 2023.9 this integration stops working entirely for me with this error logged over and over again

Source: util/logging.py:168
First occurred: 00:07:36 (3453 occurrences)
Last logged: 19:14:50

Exception in update_controller when dispatching 'truenas-update-TrueNAS': () Traceback (most recent call last): File "/config/custom_components/truenas/model.py", line 33, in update_controller model_update_items( File "/config/custom_components/truenas/model.py", line 86, in model_update_items if tmp := _register_entity(sensors, item_id, "", uid_sensor): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/truenas/model.py", line 60, in _register_entity _sensors[_item_id].async_schedule_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 901, in async_schedule_update_ha_state self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 707, in async_write_ha_state raise RuntimeError(f"Attribute hass is None for {self}") RuntimeError: Attribute hass is None for <Entity Uptime>
Exception in update_controller when dispatching 'truenas-update-TrueNAS': () Traceback (most recent call last): File "/config/custom_components/truenas/model.py", line 33, in update_controller model_update_items( File "/config/custom_components/truenas/model.py", line 93, in model_update_items if tmp := _register_entity(sensors, item_id, uid, uid_sensor): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/truenas/model.py", line 60, in _register_entity _sensors[_item_id].async_schedule_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 901, in async_schedule_update_ha_state self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 707, in async_write_ha_state raise RuntimeError(f"Attribute hass is None for {self}") RuntimeError: Attribute hass is None for <entity None=on>
Exception in update_controller when dispatching 'truenas-update-TrueNAS': () Traceback (most recent call last): File "/config/custom_components/truenas/model.py", line 33, in update_controller model_update_items( File "/config/custom_components/truenas/model.py", line 86, in model_update_items if tmp := _register_entity(sensors, item_id, "", uid_sensor): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/truenas/model.py", line 60, in _register_entity _sensors[_item_id].async_schedule_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 901, in async_schedule_update_ha_state self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 707, in async_write_ha_state raise RuntimeError(f"Attribute hass is None for {self}") RuntimeError: Attribute hass is None for <entity None=on>

How to reproduce the issue

  1. Setup integration

Expected behavior

Successful platform setup

Screenshots

Software versions

Diagnostics data

Traceback/Error logs

Additional context

psleutel commented 1 year ago

I have exactly the same problem here. Same versions. Everything was working fine before upgrade to 2023.9. After putting by backup back to previous HA version (2023.8.4), everything worked again

tomaae commented 1 year ago

Just to clarify, is this when upgrading or just when integration operates normally?

35gh commented 1 year ago

On my side, it's when the integration operates normally (it was working before the update). Thanks

tomaae commented 1 year ago

yea, its probably related to specific circumstances. we have to find them

craigwitter commented 1 year ago

Mine stopped working after the update to 2023.9 as well. I have tried removing the integration and adding it back, but still have the same error (no entries are created either).

2Wanderer commented 1 year ago

+1 i'm facing the same issue as for Truenas as well as for Portainer (i happend to use them both) both broke after updating to 2023.9, I performed a rollback, and everything was up&running normally afterwards. :)

pantherale0 commented 1 year ago

Just to clarify, is this when upgrading or just when integration operates normally?

My situation is the same as @35gh

I've not rolled back though as I'm developing some other integrations.

I'll see if I can debug in a test environment over the weekend :)

craigwitter commented 1 year ago

I wonder if this PR is at fault > https://github.com/home-assistant/core/pull/98157

On Fri, Sep 8, 2023 at 12:45 PM Jordan H @.***> wrote:

Just to clarify, is this when upgrading or just when integration operates normally?

My situation is the same as @35gh https://github.com/35gh

I've not rolled back though as I'm developing some other integrations.

I'll see if I can debug in a test environment over the weekend :)

— Reply to this email directly, view it on GitHub https://github.com/tomaae/homeassistant-truenas/issues/106#issuecomment-1711957154, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDNYG4PM2K7ZJNU7UNZQCLXZNDT7ANCNFSM6AAAAAA4PJGBZM . You are receiving this because you commented.Message ID: @.***>

CharlesCage commented 1 year ago

Another person here with the same problem and happy to help troubleshoot if anyone has ideas. I've tried the same basics of re-initializing, removing and reinstalling so far.

CharlesCage commented 1 year ago

@tomaae, I think @craigwitter is onto something.

He's specifically referencing:

Don't allow creating device if config entry does not exist

Errors from my system to support this:

Logger: homeassistant.components.update
Source: helpers/entity_platform.py:621
Integration: Update ([documentation](https://www.home-assistant.io/integrations/update), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+update%22))
First occurred: 3:04:53 PM (2 occurrences)
Last logged: 3:04:54 PM

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.28', 'connections': {('truenas', 'axiom.local')}, 'default_manufacturer': 'QEMU', 'default_model': 'Standard PC (Q35 + ICH9, 2009)', 'default_name': 'Axiom System', 'identifiers': {('truenas', 'axiom.local')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'axiom.local')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'truenas.cdc.prodbox.org')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS System', 'identifiers': {('truenas', 'truenas.cdc.prodbox.org')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.
Logger: homeassistant.components.binary_sensor
Source: helpers/entity_platform.py:621
Integration: Binary sensor ([documentation](https://www.home-assistant.io/integrations/binary_sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+binary_sensor%22))
First occurred: 3:04:53 PM (38 occurrences)
Last logged: 3:04:54 PM

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.28', 'connections': {('truenas', 'axiom.local')}, 'default_manufacturer': 'QEMU', 'default_model': 'Standard PC (Q35 + ICH9, 2009)', 'default_name': 'Axiom System', 'identifiers': {('truenas', 'axiom.local')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'axiom.local')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.28', 'connections': {('truenas', 'Axiom_Services')}, 'default_manufacturer': 'QEMU', 'default_model': 'Standard PC (Q35 + ICH9, 2009)', 'default_name': 'Axiom Services', 'identifiers': {('truenas', 'Axiom_Services')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'axiom.local')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'truenas.cdc.prodbox.org')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS System', 'identifiers': {('truenas', 'truenas.cdc.prodbox.org')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'TrueNAS_Services')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS Services', 'identifiers': {('truenas', 'TrueNAS_Services')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:621
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 3:04:53 PM (102 occurrences)
Last logged: 3:04:53 PM

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'TrueNAS_Disks')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS Disks', 'identifiers': {('truenas', 'TrueNAS_Disks')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'TrueNAS_Cloudsync')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS Cloudsync', 'identifiers': {('truenas', 'TrueNAS_Cloudsync')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'TrueNAS_Replication')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS Replication', 'identifiers': {('truenas', 'TrueNAS_Replication')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'TrueNAS_Snapshot tasks')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS Snapshot tasks', 'identifiers': {('truenas', 'TrueNAS_Snapshot tasks')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.

truenas: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.2.26', 'connections': {('truenas', 'truenas.cdc.prodbox.org')}, 'default_manufacturer': 'Supermicro', 'default_model': 'PIO-628U-TR4T+-ST031', 'default_name': 'TrueNAS System', 'identifiers': {('truenas', 'truenas.cdc.prodbox.org')}, 'sw_version': 'TrueNAS-13.0-U5.3', 'via_device': ('truenas', 'truenas.cdc.prodbox.org')} for 'truenas' config entry: device info needs to either describe a device, link to existing device or provide extra information.
CharlesCage commented 1 year ago

(And as always, appreciate all your work. This integration has been hella useful for me!)

tomaae commented 1 year ago

update dispatch is different from invalid device info. I'm working on new framework for my integrations which already adresses it, but I need to polish it a bit before it can be deployed to all integrations. hopefully next week.

Kenneth-Audenaert commented 1 year ago

Same issue, same versions and remedies tried, glad to know threre's a fix in the make.

Keep up the good work, really appreciate the integration.

tomanyusers commented 1 year ago

Another person here with the same problem

IronicRebound77 commented 1 year ago

No entities after latest HA OS update as well here

tomaae commented 1 year ago

no, thats unrelated to this issue. this one is about update dispatcher

pantherale0 commented 1 year ago

no, thats unrelated to this issue. this one is about update dispatcher

I think fixing the update dispatcher will resolve the no entities issue because all of my entities are unavailable, I assume that setting the integration up from scratch will replicate the same behaviour.

tomaae commented 1 year ago

no, its not related. I know what the other issue is and how to fix it. Just need moretime to polish the change and port it to this integration.

psleutel commented 1 year ago

Aftr the update to version 1.2.4 everyting works again. Thanks @tomaae for his great work.

IronicRebound77 commented 1 year ago

Same here, latest update 1.2.4 entities are back👍

craigwitter commented 1 year ago

Great job!

On Tue, Sep 19, 2023 at 7:53 AM IronicRebound77 @.***> wrote:

Same here, latest update 1.2.4 entities are back👍

— Reply to this email directly, view it on GitHub https://github.com/tomaae/homeassistant-truenas/issues/106#issuecomment-1725352862, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDNYGYP4W3KCXPFPAYQKTLX3GBSZANCNFSM6AAAAAA4PJGBZM . You are receiving this because you were mentioned.Message ID: @.***>

tomaae commented 1 year ago

but did you guys had this exact error?