BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
567 stars 56 forks source link

enity is no longer availible #398

Closed agilewebsolutions closed 11 months ago

agilewebsolutions commented 1 year ago

Describe the bug

This entity is no longer being provided by the octopus_energy integration. If the entity is no longer in use, delete it in settings.

Reproduction steps

all entities are univialable

Expected behaviour

should be showing the rates, been working for ages fine.

Tariff Code

No response

Integration Version

latest

Home Assistant Version

2023.9.1

Fresh Install?

Not specified

Home Assistant Logs

not sure how

neojski commented 1 year ago

Observed the same issue after installing 2023.9.1 today.

agilewebsolutions commented 1 year ago

I restored backup to previous version and it fixed it. So definitely problem with version.

neojski commented 1 year ago

I backed things out to my previous backup which, unfortunately, was 2023.6.2 but that did not fix the integration for me. I get exceptions like this:

2023-09-09 12:31:15.893 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Account for binary_sensor
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 "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 169, in async_setup_entry
    return await component.async_setup_entry(entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 179, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!

Update: after rolling back the unsuccessful rollback I checked the logs again and I still see this same thing as the first problem. So I suspect this is actually the root cause.

BottlecapDave commented 1 year ago

I've just upgraded to the latest version of HA and I'm running the latest version of the integration and not seeing this issue.

The logs that @neojski can be seen at times when reloading the integration without restarting HA. I've yet to discover why this occurs as I follow what other integrations do.

Have any of you tried restarting your instance of HA? If the API is unavailable (e.g. server errors on the API or no internet connection) during initialisation then this can produce this result. I have it on my list to raise a repair in this scenario.

If you're still not able to get the integration working, could someone please follow the faq and paste your logs in this thread along with your tariff. This can help me track down and solve the issue.

neojski commented 1 year ago

The first error I see after restart is this:

2023-09-10 00:01:11.813 ERROR (MainThread) [homeassistant.components.text] octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Electricity Meter', 'identifiers': {('octopus_energy', 'electricity_xxx')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '00050203', 'sw_version': '38040602'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information.
2023-09-10 00:01:11.816 ERROR (MainThread) [homeassistant.components.text] octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Gas Meter', 'identifiers': {('octopus_energy', 'electricity_xxx')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '47720101', 'sw_version': '03033254'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information.

I've restarted Home Assistant. I've also removed the integration and installed it back again but with no luck.

I also noticed that if I give the integration invalid API key it doesn't (visibly, not logs) complain.

neojski commented 1 year ago

I'm trying to see if I can remove the entities but I can't despite removing octopus integration. Maybe that's another lead

image

Edit: I was hoping that restarting home assistant would fix this but it didn't. So maybe this is the duplicates problem the exception above was talking about.

BottlecapDave commented 1 year ago

The first error I see after restart is this:

2023-09-10 00:01:11.813 ERROR (MainThread) [homeassistant.components.text] octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Electricity Meter', 'identifiers': {('octopus_energy', 'electricity_xxx')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '00050203', 'sw_version': '38040602'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information.
2023-09-10 00:01:11.816 ERROR (MainThread) [homeassistant.components.text] octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Gas Meter', 'identifiers': {('octopus_energy', 'electricity_xxx')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '47720101', 'sw_version': '03033254'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information.

I've restarted Home Assistant. I've also removed the integration and installed it back again but with no luck.

I also noticed that if I give the integration invalid API key it doesn't (visibly, not logs) complain.

That error got fixed in 8.0.0 of the integration. Are you sure you're using the latest version of the integration? This can be confirmed by following these instructions and pasting the contentes here.

neojski commented 1 year ago

Updating the integration fixed it. I didn't write realise that custom integrations have their own updates screen so I was running an old version. Presumably the new home assistant version somehow made it more likely to trigger that old problem.

Thanks!

BottlecapDave commented 1 year ago

No problem @neojski. Yeah the issue you mentioned was introduced in the last HA update iirc. The integration will release separately to HA. There is a sensor available via the HACS integration which can be used with an automation (or similar) to indicate if updates are available

BottlecapDave commented 1 year ago

I've just upgraded to the latest version of HA and I'm running the latest version of the integration and not seeing this issue.

Have any of you tried restarting your instance of HA? If the API is unavailable (e.g. server errors on the API or no internet connection) during initialisation then this can produce this result. I have it on my list to raise a repair in this scenario.

If you're still not able to get the integration working, could someone please follow the faq and paste your logs in this thread along with your tariff. This can help me track down and solve the issue.

@agilewebsolutions was this your problem as well? If not, are you able to supply some logs using the above methods?

agilewebsolutions commented 11 months ago

i just tried upgrading again and its still not working, everything becomes unavilaible after upgrade and tried restarting and no luck.

BottlecapDave commented 11 months ago

@agilewebsolutions Are you able to provide any HA logs that might shine a light on what's going wrong? I would need anything with the integration of sensors mentioned.

agilewebsolutions commented 11 months ago

octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Electricity Meter', 'identifiers': {('octopus_energy', 'electricity_21L4373042_1160000557263')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '00050204', 'sw_version': '38040404'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information. 12:51:55 – (ERROR) Sensor - message first occurred at 12:51:54 and shows up 17 times octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Electricity Meter', 'identifiers': {('octopus_energy', 'electricity_21L4373042_1160000557263')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '00050204', 'sw_version': '38040404'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information. 12:51:47 – (ERROR) Text - message first occurred at 12:51:47 and shows up 2 times

agilewebsolutions commented 11 months ago

octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Electricity Meter', 'identifiers': {('octopus_energy', 'electricity_21L4373042_1160000557263')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '00050204', 'sw_version': '38040404'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information. octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Gas Meter', 'identifiers': {('octopus_energy', 'gas_E6S17963392161_7492585105')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '47720101', 'sw_version': '03033254'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information.

octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Electricity Meter', 'identifiers': {('octopus_energy', 'electricity_21L4373042_1160000557263')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '00050204', 'sw_version': '38040404'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information. octopus_energy: Not adding entity with invalid device info: Invalid device info {'default_name': 'Gas Meter', 'identifiers': {('octopus_energy', 'gas_E6S17963392161_7492585105')}, 'manufacturer': '1063 - Landis and Gyr', 'model': '47720101', 'sw_version': '03033254'} for 'octopus_energy' config entry: device info needs to either describe a device, link to existing device or provide extra information.

custom_components.octopus_energy.intelligent.charge_limit::OctopusEnergyIntelligentChargeLimit is overriding deprecated methods on an instance of NumberEntity, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom integration author.

agilewebsolutions commented 11 months ago

dont really know what it means but hopefully useful for you.

it seems to have stopped working even though i had not upgraded.

BottlecapDave commented 11 months ago

@agilewebsolutions That is the same error as quoted in https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/398#issuecomment-1712762334. Are you sure you're on the latest version of the integration (now v.8.3.0)? This can be confirmed by following the instructions here and pasting the result here?

agilewebsolutions commented 11 months ago

ah so sorry looks like it had not updated last time. looks like its working now

BottlecapDave commented 11 months ago

Glad to hear :) I'll close the issue as it looks like everyone is good.

agilewebsolutions commented 11 months ago

it does keep saying unavailible from time to time but after i restart home assistant then it comes back again?

BottlecapDave commented 11 months ago

@agilewebsolutions Do you mean the entity is unavailable or the state of the entity is unavailable/unknown? If the former please upgrade to the latest release. If you're still seeing this issue, please raise a new issue with the following information, otherwise I can't help fix the problem

agilewebsolutions commented 10 months ago

is there a way to be notified when the state changes to unavailable as it keeps happening when there is an update to ha. i have an automation that turns power to office off depending on price and if its unavailible then the power does not come on and the battery dies and everyone in office goes off.

here is latest log error:

Logger: homeassistant.config_entries Source: config_entries.py:399 First occurred: 02:00:42 (1 occurrences) Last logged: 02:00:42 Error setting up entry Account for octopus_energy

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 399, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/octopus_energy/init.py", line 81, in async_setup_entry await async_setup_dependencies(hass, config) File "/config/custom_components/octopus_energy/init.py", line 125, in async_setup_dependencies account_info = await client.async_get_account(config[CONFIG_MAIN_ACCOUNT_ID]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/octopus_energy/api_client/init.py", line 343, in async_get_account await self.async_refresh_token() File "/config/custom_components/octopus_energy/api_client/init.py", line 329, in async_refresh_token token_response_body = await self.async_read_response(token_response, url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/octopus_energy/api_client/init.py", line 963, in async_read_response raise ServerError(msg) custom_components.octopus_energy.api_client.ServerError: DO NOT REPORT - Octopus Energy server error (https://api.octopus.energy/v1/graphql/): 502;

502 Bad Gateway

502 Bad Gateway


nginx

BottlecapDave commented 10 months ago

Based on that error, it looks like you're unfortunate and the APIs are down when you restart your HA instance or the integration. You could use this automation to be notified if this (or any other entity) is unavailable.

agilewebsolutions commented 10 months ago

thanks just logged back in again and its down again: https://prnt.sc/Zl9xCcDiMuU2 i will try that automation thanks.

BottlecapDave commented 10 months ago

Same error in your logs I assume?