gtdiehl / iotawatt_ha

IoTaWatt for Home Assistant
Apache License 2.0
16 stars 16 forks source link

Error starting integration since HA 2023.5 upgrade #42

Open vanislman opened 1 year ago

vanislman commented 1 year ago

After upgrading to Homassistant 2023.5, this integration no longer works.

The HA log file shows following error:

Logger: homeassistant.config_entries Source: custom_components/iotawatt/init.py:16 Integration: IoTaWatt First occurred: 09:05:55 (1 occurrences) Last logged: 09:05:55 Error setting up entry iotawatt for iotawatt

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/iotawatt/init.py", line 16, in async_setup_entry hass.config_entries.async_setup_platforms(entry, PLATFORMS) AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'

nightcrawler2164 commented 1 year ago

IotaWatt is natively supported through a HomeAssistant integration. It was release in the 2021.9 version, and I don't believe we need a custom component to use it. I was using the custom integration until today, but switched to the native because I received the same error like you did. Everything's back to working now! cheers.

vanislman commented 1 year ago

Thanks for your reply here. How did you make the switch? Could you please briefly highlight the steps?

I like to do the same thing in 2023.4 version (I restored that), and migrate to the "official" iotawatt integration before upgrading HA again.

nightcrawler2164 commented 1 year ago

tbh, I did the migration to using the official integration AFTER migrating to 2023.5.1. It was pretty straight forward. Please make any backups as needed before doing the below steps in case you encounter data loss of any sorts.

  1. Delete the current integration that references the custom component
  2. Delete the custom component
  3. Restart Home Assistant
  4. Install IotaWatt official integration from the Home Assistant integrations page

Once I did steps 1-4, all my existing data showed up. I think this should work for you as well.

vanislman commented 1 year ago

Thanks for the help, that worked ! I didn't expect that all sensors and history would be kept. Very smooth switch!

darek-margas commented 1 year ago

I fixed this in my fork and added PR to merge it here. The one embedded in HA itself has issues with removed UUIDs so that entities from outputs can't be edited in UI. Switching to native likely renames all sensors. I didn't want to switch. Use my fork if you want or one day it may get merged here (or fixed otherwise).

agentadam-code commented 1 year ago

@karthikvenkat123, I was also having issues since 2023.5.0. Upgraded to .5.2 which did not resolve. I have followed your steps and it is now working but as @darek-margas points out, the official one does not add in outputs. Using @darek-margas's fork is working for me now. Hope for some collaboration on merging to the official release sometime in the future. I had no idea there were so many versions of this integration floating around!

vanislman commented 1 year ago

The official integration has issues with Inputs, but only in one way: You cannot edit the names/entities, but they actually do show up. I have the "official" integration working with all inputs working - as long as you can accept the names which are generated automatically. The migration was really smooth, just delete the custom integration, reboot, install the "official" integration - and it kept all data and all entities from the custom integration.

darek-margas commented 1 year ago

It is mixed problem. First these silly names and inability to set them any other way than in yaml. Then, while inputs are showing up, outputs are hidden. They do appear but HA does not recognize them as sensors from Iotawatt. This is why I haven't found them at first go. It is a mess but one which HA demanded. For HA dev team Iotawatt does not provide sensor with id being unique enough so that to integrate within, this integration had to be screwed up to have no unique IDs. The one here has them. Personally I want them regardless of politics biased fight in HA team. It is politics only as what is documented allows what Iotawatt has just not for Iotawatt. So, it is not a failure or a bug which needs a fix, it is forced to be broken as a condition of merge into HA code.

agentadam-code commented 1 year ago

Very interesting. As a user, I need my inputs and custom outputs. So the official one would be fine if I was only using my inputs but part of IotaWatt’s brilliance is it’s outputs feature. I export both inputs and outputs to a database too. And the only real way of getting accurate data in the energy dashboard is by using outputs too. Anyway, hope something can be resolved going forward. It clearly works as a HACS component. So I hope they get over any policy stuff and make it work because it’s a brilliant device.

darek-margas commented 1 week ago

I updated my fork to backport all the changes from core up to 2024.8 while retaining outputs with unique IDs. I may actually push a PR yet this repo seems dormant, hence unlikely to merge here. I think easiest way is to add my fork into HACS.