I want to put scrape code directly in the yaml instead of using the visual part of the integration and I can’t get it to work… any ideas? This is the code, if I configure it from the visual with the same data it works but if I put this code in the sensors section, when I restart the system the sensor doesn’t even appear.
Registrador: homeassistant.components.sensor
Fuente: helpers/entity_platform.py:633
integración: Sensor (documentación, problemas)
Ocurrió por primera vez: 23:49:24 (1 ocurrencias)
Última vez registrado: 23:49:24
Error adding entity sensor.aceite_de_prueba for domain sensor with platform scrape
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 640, in state
numerical_value = float(value) # type:ignore[arg-type]
ValueError: could not convert string to float: '\r\n\t\t\t\t\t\t\t\t$3,129.00\r\t'
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 633, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 972, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1383, in add_to_platform_finish
await self.async_added_to_hass()
File "/usr/src/homeassistant/homeassistant/components/scrape/sensor.py", line 206, in async_added_to_hass
self.async_write_ha_state()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1023, in async_write_ha_state
self._async_write_ha_state()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1148, in _async_write_ha_state
self.__async_calculate_state()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1085, in __async_calculate_state
state = self._stringify_state(available)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1029, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 642, in state
raise ValueError(
...<5 lines>...
) from err
ValueError: Sensor sensor.aceite_de_prueba has device class 'None', state class 'None' unit 'ARS' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '
$3,129.00
' (<class 'str'>)