rs443
January 25, 2019, 8:00am
1
I successfully managed to create sensor that adds 7 to the value. The issue is that the Telldus API loses connection several times a day and reports ‘unavailable’. The template then adds 0+7 = 7. This makes the graphs screw up.
Do you have an idea how to fix this problem?
- platform: template
sensors:
krypgrund_humidity_offset:
value_template: '{{ (states.sensor.krypgrund_humidity.state | float + 7) | round(0) }}'
unit_of_measurement: '%'
tom_l
January 25, 2019, 8:07am
2
Try this instead:
value_template: "{{ (states('sensor.krypgrund_humidity') | float + 7) | round(0) }}"
rs443
January 25, 2019, 8:40am
4
Thank you! I have set up a sensor based on your suggestion. Now wait for an API-timeout.
rs443
January 25, 2019, 3:39pm
5
It did not seem to work The issue persists:
finity
January 26, 2019, 4:17am
6
try this for the template:
value_template: >
{% if states.sensor.krypgrund_humidity.state != 'unavailable' %}
{{ (states.sensor.krypgrund_humidity.state | float + 7) | round(0) }}
{% else %}
{{ states.sensor.krypgrund_humidity_offset.state }}
{% endif %}
rs443
January 27, 2019, 3:12pm
8
It almost worked. The state probably was something else than unavailable, possibly unknown, null or similar.
This modification did the trick:
value_template: >-
{% if states('sensor.krypgrund_humidity') | float > 40 %}
{{ (states('sensor.krypgrund_humidity') | float + 7) | round(0) }}
{% else %}
{{ states('sensor.krypgrund_humidity_offset') }}
{% endif %}
Thank you!