home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.11k stars 29.16k forks source link

Geizhals Integration #38123

Closed bussio closed 3 years ago

bussio commented 4 years ago

The problem

For some time now, the integration Geizhals (https://www.home-assistant.io/integrations/geizhals/) no longer seems. No matter what I specify as a product id, no sensor is generated.

Environment

Problem-relevant configuration.yaml

This is the entry in the sensor.yaml:

# Geizhals sensor will give you the best price of a product 
# https://www.home-assistant.io/integrations/geizhals/
  - platform: geizhals 
    name: Raspi
    product_id: 2081132
    description: "Raspberry 4B 4GB"

Traceback/Error logs

2020-07-23_17-45-21

Additional information

probot-home-assistant[bot] commented 4 years ago

geizhals documentation geizhals source (message by IssueLinks)

Armadill0 commented 3 years ago

I have the exact same problem.

Homeassistant: 0.117.4 in Hassio Error log:

Logger: homeassistant.components.sensor
Source: components/geizhals/sensor.py:94
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: 5:07:59 PM (1 occurrences)
Last logged: 5:07:59 PM

geizhals: Error on device update!

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 357, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 239, in wrapper result = method(*args, **kwargs) File "/usr/src/homeassistant/homeassistant/components/geizhals/sensor.py", line 94, in update self._device = self._geizhals.parse() File "/usr/local/lib/python3.8/site-packages/geizhals/geizhals.py", line 78, in parse self.device.name = raw.string.replace('\n', '') AttributeError: 'NoneType' object has no attribute 'string'

My config:

sensor:
  - platform: geizhals
    name: geizhals-amd-ryzen9-5950x
    description: AMD Ryzen 9 5950X
    product_id: 2392527
    locale: DE
github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

timherrm commented 3 years ago

Version core-2021.2.1 Newest Version currently and still no sensor being created.

  - platform: geizhals
    name: udm
    product_id: 2227937
    description: "Unifi Dream Machine Pro"
    locale: "DE"
2021-02-05 17:22:30 ERROR (MainThread) [homeassistant.components.sensor] geizhals: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 358, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
await task
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 285, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/geizhals/sensor.py", line 94, in update
self._device = self._geizhals.parse()
File "/usr/local/lib/python3.8/site-packages/geizhals/geizhals.py", line 78, in parse
self.device.name = raw.string.replace('\n', '')
AttributeError: 'NoneType' object has no attribute 'string'
timherrm commented 3 years ago

Found the error in the "geizhals.py" lib. Geizhals has changed their website layout, so the beautifulsoup search does not return the right results. In geizhals.py replace line 77 with: raw = soup.find('h1', attrs={'class': 'variant__header__headline'}) and line 114 with '.variant__header__options-list__item-link')[0].attrs['href']

I tried to create a pull request, but the repo is read-only. So here is my fork: https://github.com/timherrm/geizhals I wrote an e-mail to the repo owner, maybe he will answer me and accept the pull request.

timherrm commented 3 years ago

Quick, but temporary fix is to ssh into your home-assistant machine, open an interactive shell into the homeassistant-docker container and edit the file with "vi". Be careful, as you can damage your home-assistant installation, if you don't know what you are doing. This fix survives a home assistant reboot, but not an upgrade. image