@mdfoto wrote:
Hi,
I hope somebody can help me with the following issue. I control my lights based on outside light levels using a NodeMCU with ESPhome on it. A simple setup using a LDR. Before this setup, i done it with the same LDR and MQTT (non ESPHome). The LDR gives a value and with the template sensor i do some math(own mapping calculation) stuff to set the light brightness level.
With my previous setup (MQTT) i didn’t had any problems. With my new setup (ESPHome) Hassio does detect when the sensor isn’t available. That results in a sensor value ‘unavailable’. For now i made a workaround to detect that value and set a sensor to 0 or 1. In the automation script i only set new brightness levels if the sensor is not 0 = ‘unavailable’ using a condition.I can’t figure out how to handle this in the sensor template itself. If i using INT or FLOAT and the sensor value isn’t numeric it has an outcome. I suspected something else…
Is there a trick to not update a template sensor when the ESPHOME sensor is ‘unavailable’?
My brightness math:
value_template: '{{((((states.sensor.living_room_brightness.state | int - 1) * (1 - (states.input_number.maxbright.state) | int) / (states.input_number.maxldr.state | int -1 ) + (states.input_number.maxbright.state) | int ) | int -1) | float * (states.sensor.brightfactor.state) | float) | int}}
If the room_brightness is a string (no numeric) it will always result in the maxbright state.
Hope you understand my problem.
If any info is needed, let me know.
Posts: 11
Participants: 4