Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error fetching sensor data: 'int' object has no attribute 'text' #24

Open
BrianKnudsen opened this issue Sep 23, 2023 · 10 comments

Comments

@BrianKnudsen
Copy link

Unexpected error fetching sensor data: 'int' object has no attribute 'text'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 293, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 248, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/sensor.py", line 39, in async_update_data
await hass.async_add_executor_job(company.refreshPrices)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_api.py", line 202, in refreshPrices
self._products = getattr(self._parser, self._key)(self._url, self._products)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_parsers.py", line 93, in shell
return self._getDataFromTable(url, products, 0, -1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_parsers.py", line 202, in _getDataFromTable
html = self._get_html_soup(r)
^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_parsers.py", line 197, in _get_html_soup
if r.text:
^^^^^^
AttributeError: 'int' object has no attribute 'text'

@mm98
Copy link

mm98 commented Sep 28, 2023

See #25

@BrianKnudsen
Copy link
Author

BrianKnudsen commented Sep 28, 2023

if found:
priceSegments = cells[2].findAll(
"span", style=["text-align:right;", "text-align:left;"]
)
if priceSegments:
products[productKey] = self._addPriceToProduct(
productDict,
priceSegments[0].text + "." + priceSegments[1].text,
)

Hvis det er denne som skal tilføres.. ??
Så har jeg tilføjret den.. Og det har også virket med det fix. Men får den fejl nu

@mm98
Copy link

mm98 commented Sep 28, 2023

Denne del (fuelprices_dk_parsers.py, linje 129):

                    if found:
                        priceSegments = cells[2].findAll(
                            "span", style=["text-align:right;", "text-align:left;"]
                        )
                        products[productKey] = self._addPriceToProduct(
                            productDict,
                            priceSegments[0].text + "." + priceSegments[1].text,
                        )

Skal erstattes med:

                    if found:
                        products[productKey] = self._addPriceToProduct(
                            productDict,
                            cells[2].text,
                        )

Vent evt. til at denne PR bliver indlæst i koden af @J-Lindvig

@BrianKnudsen
Copy link
Author

Med den ændre som du har skrevet, for jeg den fejl som også jeg har skrevet

Unexpected error fetching sensor data: 'int' object has no attribute 'text'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/sensor.py", line 39, in async_update_data
await hass.async_add_executor_job(company.refreshPrices)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_api.py", line 202, in refreshPrices
self._products = getattr(self._parser, self._key)(self._url, self._products)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_parsers.py", line 93, in shell
return self._getDataFromTable(url, products, 0, -1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_parsers.py", line 202, in _getDataFromTable
html = self._get_html_soup(r)
^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/fuelprices_dk/fuelprices_dk_parsers.py", line 197, in _get_html_soup
if r.text:
^^^^^^
AttributeError: 'int' object has no attribute 'text'

@mm98
Copy link

mm98 commented Sep 28, 2023

Could you check, if you have changed these also? circlek changed the titles of their products.

8097a48

@BrianKnudsen
Copy link
Author

BrianKnudsen commented Sep 28, 2023

Den har jeg også lavet.

@mm98
Copy link

mm98 commented Sep 28, 2023

Jeg kan se, at Shell har ændret deres hjemmeside. Jeg vil formode, at hvis du fjerner Shell fra din konfiguration - så vil det måske virke? .. ellers må jeg melde pas (jeg har ikke selv shell aktiveret og her virker det uden problemer).

@BrianKnudsen
Copy link
Author

Hvis jeg sætter Shell ind som companies under configuration.yaml for jeg stadig at de alle sammen er utilgængelig og sammen fejl i loggen

@mm98
Copy link

mm98 commented Sep 28, 2023

Du burde egentlig fjerne shell fra companies:. Når den er angivet der, så indlæses den også.

Min ser f.eks. sådan ud og giver ikke fejl eller unavailable.

fuelprices_dk:
  update_interval: 30
  companies:
    - circlek
    - f24
    - goon
    - ingo
    - oil
    - ok
    - q8
  fueltypes:
    - oktan 95

@BrianKnudsen
Copy link
Author

Jeg havde ikke skrevet noget under companies.. Så min var bar tom.. det var det der skulle til..

Og den kommer heller ikke med fejl i loggen.

jeg siger mange tak for hjælpen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants