would you recognize this error:
2018-07-20 09:50:24 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.circadian_light fails
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 196, in async_update_ha_state
yield from self.async_device_update()
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 317, in async_device_update
yield from self.async_update()
File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 212, in coro
res = func(*args, **kw)
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/template.py", line 183, in async_update
self._state = self._template.async_render()
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/template.py", line 132, in async_render
return self._compiled.render(kwargs).strip()
File "/usr/local/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 3, in top-level template code
TypeError: can't multiply sequence by non-int of type 'float'
which change would you suggest to mitigate the error in these 2 sensors:
- platform: template
sensors:
length_of_day_factor:
friendly_name: 'Length of day' # factor for circadian light calculation'
value_template: >
{% set daylength = ((as_timestamp(states.sun.sun.attributes.next_setting) -
as_timestamp(states.sun.sun.attributes.next_rising)) /
3600) + 24 %}
{{ ((daylength*-0.0063616)+0.11131)|round(5) }}
circadian_light:
friendly_name: 'Circadian light'
unit_of_measurement: 'mired'
value_template: >
{% if is_state('sun.sun' , 'above_horizon') %}
{{ ((states.sensor.length_of_day_factor.state | round (5)) *
((states.sun.sun.attributes.azimuth)-180)**2 + 175) | int }}
{% elif (as_timestamp(states.sun.sun.attributes.next_dusk)) -
(as_timestamp(states.sun.sun.attributes.next_setting)) < 0 or
(as_timestamp(states.sun.sun.attributes.next_rising)) -
(as_timestamp(states.sun.sun.attributes.next_dawn)) < 0 %}
350
{% else %}
390
{% endif %}
not sure if the error is caused by the HA startup sequence not having set the value correctly yet, or the template is not correct?
Thx for having another check,
Marius