danieldotnl/ha-multiscrape

Problem reading a unique id that contains a dot

Closed this issue · 5 comments

Hi, I have a problem, the first PM10 reading works for me, but the second for PM2.5 doesn't work for me, I assume the problem is in the dot. Please help me find a solution.

Please provide debug logging.

Logger: custom_components.multiscrape.sensor
Source: custom_components/multiscrape/sensor.py:159
integration: Multiscrape (documentation, issues)
First occurred: 23:02:52 (1 occurrences)
Last logged: 23:02:52

A_PM2_5 # PM2.5 # Unable to scrape data: Could not find a tag for given selector Consider using debug logging and log_response for further investigation.


2024-11-16 00:56:59.087 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.a_pm2_5_2 for domain sensor with platform multiscrape
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 664, in state
numerical_value = float(value) # type:ignore[arg-type]
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unavailable'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 599, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 918, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1368, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
self.__async_calculate_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1069, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1013, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 666, in state
raise ValueError(
ValueError: Sensor sensor.a_pm2_5_2 has device class 'None', state class 'None' unit 'µg/m³' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unavailable' (<class 'str'>)

Do you have any solution? TNX

It's an issue with the BeautifulSoup library I'm using for scraping.
It works if you escape the value like this: select: 'pm2\.5'

PS: you now just get the first result. I guess you should select based on the 'sifra'..

tnx u ROCK!