hi i trying to fix a couple errors i get in the logs
first logs say
Logger: homeassistant.helpers.template
Source: helpers/template.py:2667
First occurred: 12:19:47 PM (1 occurrences)
Last logged: 12:19:47 PM
Template variable error: 'dict object' has no attribute 'weather.peterborough_forecast' when rendering '{{ is_number(hourly['weather.peterborough_forecast'].forecast[0].temperature) }}'
Logger: homeassistant.helpers.sensor
Source: helpers/trigger_template_entity.py:204
First occurred: 12:19:47 PM (1 occurrences)
Last logged: 12:19:47 PM
Error rendering availability template for sensor.temperature_forecast_next_hour: UndefinedError: 'dict object' has no attribute 'weather.peterborough_forecast'
Logger: homeassistant.helpers.service
Source: helpers/service.py:302
First occurred: 12:19:47 PM (1 occurrences)
Last logged: 12:19:47 PM
Referenced entities weather.peterborough_forecast are missing or not currently available
i try to add default nan to add not avalible but its not working either so not sure what to do here is what i did i tried
template:
- trigger:
- platform: time_pattern
hours: /1
- platform: homeassistant
event: start
action:
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id:
- weather.peterborough_forecast
- weather.home
response_variable: hourly
sensor:
- name: Today Rain
unique_id: today_rain
state: "{{ (hourly['weather.home'].forecast[0].precipitation | default('nan')) }}"
#state: "{{ forecast['weather.home'].forecast[0].precipitation }}"
availability: "{{ is_number(hourly['weather.home'].forecast[0].precipitation ) }}"
unit_of_measurement: mm
- name: Temperature forecast next hour
unique_id: temperature_forecast_next_hour
state: "{{ hourly(['weather.peterborough_forecast'].forecast[0].temperature | default('nan'))}}"
#state: "{{ forecast['weather.peterborough_forecast'].forecast[0].temperature }}"
availability: "{{ is_number(hourly['weather.peterborough_forecast'].forecast[0].temperature) }}"
my other issue is temperatures i made bunch of templates to read from sensors but when a value goes unknown it throws me error how do i fix that
Logger: homeassistant.core
Source: core.py:1562
First occurred: 12:19:47 PM (14 occurrences)
Last logged: 12:19:47 PM
Error running job: <Job onetime listen homeassistant_start <function _async_at_core_state.<locals>._matched_event at 0x7f69dd365620> HassJobType.Callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f69dd365620>>>
Error running job: <Job onetime listen homeassistant_start <function _async_at_core_state.<locals>._matched_event at 0x7f69dd365da0> HassJobType.Callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f69dd365da0>>>
Error running job: <Job onetime listen homeassistant_start <function _async_at_core_state.<locals>._matched_event at 0x7f69dd366020> HassJobType.Callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f69dd366020>>>
Error running job: <Job onetime listen homeassistant_start <function _async_at_core_state.<locals>._matched_event at 0x7f69dd3667a0> HassJobType.Callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f69dd3667a0>>>
Error running job: <Job onetime listen homeassistant_start <function _async_at_core_state.<locals>._matched_event at 0x7f69dd366a20> HassJobType.Callback <_OneTimeListener homeassistant.helpers.start:<function _async_at_core_state.<locals>._matched_event at 0x7f69dd366a20>>>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 657, in state
numerical_value = int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 660, in state
numerical_value = float(value)
^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 1562, in async_fire_internal
self._hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 937, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/core.py", line 1423, in __call__
self.hass.async_run_hass_job(self.listener_job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 937, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 44, in _matched_event
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 937, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 487, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1122, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1308, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 937, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 436, in _handle_results
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
self.__async_calculate_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 664, in state
raise ValueError(
ValueError: Sensor sensor.basement_backroom_temperature has device class 'temperature', state class 'None' unit '°C' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)
my template for this one is
- name: "Basement Backroom Temperature"
state: "{{ states('sensor.bluetooth_server_2_basement_backroom_temperature_xiaomi'| default('nan')) }}"
icon: "mdi:thermometer"
unit_of_measurement: "°C"
device_class: temperature
- name: "Basement Backroom Humidity"
state: "{{ states('sensor.bluetooth_server_2_basement_backroom_humidity_xiaomi'| default('nan')) }}"
icon: "mdi:water-percent"
unit_of_measurement: "%"
device_class: humidity
i tried the nan also but doesnt work… so not sure what to do…