HAsmartirrigation: [Bug] Error adding entities for domain sensor with platform smart_irrigation
Describe the bug Upon HA start-up I get the following error:
2023-07-12 03:33:37.271 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform smart_irrigation
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 504, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 788, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 742, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in _async_write_ha_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/config/custom_components/smart_irrigation/sensor.py", line 557, in state
self._state = self.update_state()
^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/smart_irrigation/sensor.py", line 516, in update_state
self.evapotranspiration = self.get_evapotranspiration(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/smart_irrigation/sensor.py", line 694, in get_evapotranspiration
t_dew = float(data["dew_point"])
~~~~^^^^^^^^^^^^^
KeyError: 'dew_point'
To Reproduce Steps to reproduce the behavior:
- Upon Home Assistant startup
- See error
Expected behavior A clear and concise description of what you expected to happen.
My configuration Using in sensors-only mode, no OWM:
{
"version": 1,
"domain": "smart_irrigation",
"title": "Smart Irrigation",
"data": {
"number_of_sprinklers": 6.0,
"flow": 12.0,
"area": 135.0,
"api_key": null,
"reference_evapotranspiration": [
0.2,
0.2,
2.2,
2.2,
2.2,
3.9,
5.4,
3.5,
0.2,
0.2,
0.2,
0.2
],
"name": "Smart Irrigation",
"sources": {
"use_owm_precipitation": false,
"use_owm_temperature": false,
"use_owm_min_temperature": false,
"use_owm_max_temperature": false,
"use_owm_dewpoint": false,
"use_owm_pressure": false,
"use_owm_humidity": false,
"use_owm_windspeed": false,
"calculate_solar_radiation": false,
"calculate_ET_value": true
},
"sensors": {
"sensor_precipitation": "sensor.icorun3_precipitation_today",
"sensor_temperature": "sensor.weather_outside_temperature",
"sensor_min_temperature": "sensor.aggregation_temperature_daily_outside_min",
"sensor_max_temperature": "sensor.aggregation_temperature_daily_outside_max",
"sensor_dewpoint": "sensor.icorun3_dewpoint",
"sensor_pressure": "sensor.icorun3_pressure",
"sensor_humidity": "sensor.weather_outside_humidity",
"sensor_windspeed": "sensor.icorun3_wind_speed",
"sensor_solar_radiation": "sensor.icorun3_solar_radiation"
}
},
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"unique_id": "Smart Irrigation",
"disabled_by": null
}
Installed version 0.0.79
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (18 by maintainers)
Commits related to this issue
- Version 0.0.81: Fixes #144 and W/sq ft to W/m2 conversion bug — committed to jeroenterheerdt/HAsmartirrigation by jeroenterheerdt a year ago
thanks, yeah, I think the
initial_update_delay
doesn’t work as intended so this is the best we can do at the moment.I’m not too good at Python, but I’ll make a small PR. From what I see in the code, the “initial_update_delay” is working properly, however I don’t think it’s serving the purpose we are talking about here. At least from the little I understood in the code.
Best I can do with a PR is handle the exception in the
get_evapotranspiration
method so that it will not fail upon adding entities to HA.thanks, not sure what is going on with me today, but I totally missed that. Can you tell me what your
sensor.icorun3_dewpoint
entity returns?