core: pi-hole broken after updating pi-hole web to 5.18

The problem

After updating pi-hole (and FTL and AdminLTE), all sensors except the update information are no longer available. Release notes AdminLTE: https://github.com/pi-hole/AdminLTE/releases/tag/v5.18

sensors

What version of Home Assistant Core has the issue?

core-2022.12.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

pihole

Link to integration documentation on our website

https://www.home-assistant.io/integrations/pi_hole/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-12-22 07:59:53.460 ERROR (MainThread) [homeassistant.components.binary_sensor] Error adding entities for domain binary_sensor with platform pi_hole
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 692, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
if (is_on := self.is_on) is None:
File "/usr/src/homeassistant/homeassistant/components/pi_hole/binary_sensor.py", line 87, in is_on
return self.entity_description.state_value(self.api)
File "/usr/src/homeassistant/homeassistant/components/pi_hole/const.py", line 164, in <lambda>
state_value=lambda api: bool(api.data.get("status") == "enabled"),
AttributeError: 'list' object has no attribute 'get'
2022-12-22 07:59:53.471 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform pi_hole
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/pi_hole/sensor.py", line 69, in native_value
return round(self.api.data[self.entity_description.key], 2)
TypeError: list indices must be integers or slices, not str
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 692, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 680, in state
value = self.native_value
File "/usr/src/homeassistant/homeassistant/components/pi_hole/sensor.py", line 71, in native_value
return self.api.data[self.entity_description.key]
TypeError: list indices must be integers or slices, not str
2022-12-22 07:59:53.555 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up pi_hole platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 692, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
if (is_on := self.is_on) is None:
File "/usr/src/homeassistant/homeassistant/components/pi_hole/binary_sensor.py", line 87, in is_on
return self.entity_description.state_value(self.api)
File "/usr/src/homeassistant/homeassistant/components/pi_hole/const.py", line 164, in <lambda>
state_value=lambda api: bool(api.data.get("status") == "enabled"),
AttributeError: 'list' object has no attribute 'get'
2022-12-22 07:59:53.561 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up pi_hole platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/pi_hole/sensor.py", line 69, in native_value
return round(self.api.data[self.entity_description.key], 2)
TypeError: list indices must be integers or slices, not str
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 692, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 680, in state
value = self.native_value
File "/usr/src/homeassistant/homeassistant/components/pi_hole/sensor.py", line 71, in native_value
return self.api.data[self.entity_description.key]
TypeError: list indices must be integers or slices, not str
2022-12-22 07:59:54.273 ERROR (MainThread) [homeassistant.components.binary_sensor] pi_hole: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 493, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 715, in async_device_update
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 392, in async_update
await self.coordinator.async_request_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 175, in async_request_refresh
await self._debounced_refresh.async_call()
File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 82, in async_call
await task
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 201, in async_refresh
await self._async_refresh(log_failures=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 316, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 121, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 381, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in _async_write_ha_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 551, in _stringify_state
if (state := self.state) is None:
File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
if (is_on := self.is_on) is None:
File "/usr/src/homeassistant/homeassistant/components/pi_hole/binary_sensor.py", line 87, in is_on
return self.entity_description.state_value(self.api)
File "/usr/src/homeassistant/homeassistant/components/pi_hole/const.py", line 164, in <lambda>
state_value=lambda api: bool(api.data.get("status") == "enabled"),
AttributeError: 'list' object has no attribute 'get'

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 60 (16 by maintainers)

Most upvoted comments

not an issue 🙂 will work on a fix later this day

Just updated to 2023.1.0 but I am still getting this:

Logger: homeassistant.components.sensor
Source: components/pi_hole/sensor.py:71
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 01:50:03 (2 occurrences)
Last logged: 01:50:03

Error adding entities for domain sensor with platform pi_hole
Error while setting up pi_hole platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/sensor.py", line 69, in native_value
    return round(self.api.data[self.entity_description.key], 2)
TypeError: list indices must be integers or slices, not str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 438, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 709, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 804, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 562, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 855, in state
    value = self.native_value
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/sensor.py", line 71, in native_value
    return self.api.data[self.entity_description.key]
TypeError: list indices must be integers or slices, not str
Logger: homeassistant.components.sensor
Source: components/pi_hole/const.py:164
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 01:50:04 (1 occurrences)
Last logged: 01:50:04

pi_hole: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 503, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 729, in async_device_update
    await task
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 392, in async_update
    await self.coordinator.async_request_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 175, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 82, in async_call
    await task
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 201, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 316, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 121, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 381, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 562, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
    if (is_on := self.is_on) is None:
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/binary_sensor.py", line 87, in is_on
    return self.entity_description.state_value(self.api)
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/const.py", line 164, in <lambda>
    state_value=lambda api: bool(api.data.get("status") == "enabled"),
AttributeError: 'list' object has no attribute 'get'
Logger: homeassistant.components.binary_sensor
Source: components/pi_hole/const.py:164
Integration: Binary sensor ([documentation](https://www.home-assistant.io/integrations/binary_sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+binary_sensor%22))
First occurred: 01:49:06 (3 occurrences)
Last logged: 01:49:06

Error adding entities for domain binary_sensor with platform pi_hole
Error while setting up pi_hole platform for binary_sensor
pi_hole: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 438, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 709, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 804, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 562, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
    if (is_on := self.is_on) is None:
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/binary_sensor.py", line 87, in is_on
    return self.entity_description.state_value(self.api)
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/const.py", line 164, in <lambda>
    state_value=lambda api: bool(api.data.get("status") == "enabled"),
AttributeError: 'list' object has no attribute 'get'
Logger: homeassistant
Source: components/pi_hole/const.py:164
First occurred: 01:55:04 (1 occurrences)
Last logged: 01:55:04

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 316, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 121, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 381, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 562, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
    if (is_on := self.is_on) is None:
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/binary_sensor.py", line 87, in is_on
    return self.entity_description.state_value(self.api)
  File "/usr/src/homeassistant/homeassistant/components/pi_hole/const.py", line 164, in <lambda>
    state_value=lambda api: bool(api.data.get("status") == "enabled"),
AttributeError: 'list' object has no attribute 'get'

I have already restarted HA as well.

What is needed to get it working again?

After 2023.1.0 I am still not having any success. I have unloaded and re-loaded Pi-hole integration, but am still only getting the update sensors. For all other sensors, I’m getting this message: This entity is no longer being provided by the pi_hole integration. If the entity is no longer in use, delete it in settings.

Getting this in HA logs: Error adding entities for domain binary_sensor with platform pi_hole 7:50:24 PM – (ERROR) Binary sensor - message first occurred at 7:49:33 PM and shows up 6 times Error adding entities for domain sensor with platform pi_hole 7:50:24 PM – (ERROR) Sensor - message first occurred at 7:49:33 PM and shows up 4 times

Do I need to do something else?

Issue has been fiexed in 2023.1.0, and confirmed working.

Thanks everyone!

For what it’s worth, applying the changes in this PR, fixed the issue for me. So if this is causing you pain that’s a potential stop-gap. It’s just two lines in the init.py for hole.

That sounds very promising. Could you tell me where to find this file? I’m running HA OS, maybe I need to login to the homeassistant container first.


Update: found it, solved it (temporarily until I can update HA Core to latest 2022.12):

  1. docker exec -it homeassistant bash
  2. vi /usr/local/lib/python3.10/site-packages/hole/__init__.py --> apply changes --> save
  3. restart HA

@bcutter the issue is already tagged with milestone 2022.12.9 so will be probably fixed next release. But hey it’s Open source and anyone even you can participate by fixing, improving or helping to. Nobody to blame. Every release with any Software can fix and cause new bugs. And yeah If you want to know you can downgrade pihole by switching the branch/tag but could be risky as every downgrade, couple weeks ago had to downgrade pihole after random ftl crashes.

Thanks all! I had to take off the Statistics only, then it prompted for API key and was successful.

For what it’s worth, applying the changes in this PR, fixed the issue for me. So if this is causing you pain that’s a potential stop-gap. It’s just two lines in the init.py for hole.

Crap… had i know this… ah well…

I think there is a problem in the ui setup. Try unchecking “statistics only”. In the next step it should ask for api key.

Analyzing code I think it seems to not ask for that if statistic only is checked. But will try it later in my instance.

For me currently everything works and is running after 2023.1. But I had API key configuered before.

The API is not asked when adding the pi hole integration. Tried to see if there’s a pi hole file in the config folder but didn’t see anything

i think the api endpoint should be summaryRaw instead of summary … will update it in https://github.com/home-assistant-ecosystem/python-hole/pull/14

- params = "summary&auth={}".format(self.api_token)
+ params = "summaryRaw&auth={}".format(self.api_token)

I removed the integration and added it back. You uncheck the checkbox for “Only Statistics” when you re-add the integration. You’ll be prompted for a Token then. You get the Token via settings/API in in the Pi Hole Web Interface.

Thanks that did it.

Sorry, my mistake. After using the integration with a Token it works. So thanks for mentioning the Fix!

How do you use the token?

I removed the integration and added it back. You uncheck the checkbox for “Only Statistics” when you re-add the integration. You’ll be prompted for a Token then. You get the Token via settings/API in in the Pi Hole Web Interface.

No fingerpointing, just the first feeling when running into this, unnecessarily. Sometimes I forget that even core integrations are not “protected” of running into such avoidable issues - software is what it is, you’re right.

But it is kinda fingepointing in my eyes. But what really makes be angry is on the one hand saying

I was aware of https://pi-hole.net/blog/2022/11/17/upcoming-changes-authentication-for-more-api-endpoints-required/ already a month ago and fixed all my stuff, including some custom parts in my own pihole.yaml - I did my homework. I expected (tbh: didn’t even think about this could not be the case) the official Pi-Hole integration would have taken care of this already…

linking a post from latest month that even when the pihole integration had this on the map and already implemented. Would it be probably fixed in the 2022.12 release but then telling

As I’m running an older HA Core version (so I can’t update to latest 2022.12 quickly) I’m curious about

This really makes to sense to me on the one hand saying YOU did your homework and the pihole integrations maintainers not but even when they had this on the map YOU would have ran into this “avoidable issue” … contradictory

Sorry I know it is a little bit offtopic and not adding anything informative to the actual issue/topic. But I just want to point out that things like this happen and can not be expected from a free (excluding nabu casa users) product which rely on community contributions. This reminds me of javascript developers deleting their free to use libraries because of fingerpointing, threatening etc. I know that the issue has impact on some of the home assistant instances (mine included) but just be patient and polite 😃

I am thankful for every “workaround” and also for the fast reaction of initiating a fix of such impacting problems @mib1185 😃

as I wrote in https://github.com/home-assistant/core/issues/84422#issuecomment-1362814271 the used python library needs to be updated to use the token during api call