I’m trying to turn a fan on just before the sunrise (-1º) and turn if off just after the sunrise (+2º) but when I uploaded this to my device at 3pm, the sun was FAR away from these values and it fired unexpectedly! This is actually the second time I’ve tried this and seen it trigger at the wrong time.
Here’s my log:
I expected the sun-based trigger only to happen when the sun.elevation went exactly through the defined point and should not trigger at any other time, is that the case? What am I missing here?
Here’s my ESPHome YAML:
text_sensor:
- platform: template
name: "${friendly_name} Change Reason"
id: ${node_name}_change_reason
update_interval: never
icon: mdi:math-log
time:
- platform: homeassistant
sun:
latitude: !secret latitude
longitude: !secret longitude
on_sunrise:
- elevation: -1°
then:
- fan.turn_on:
id: ${node_name}
- logger.log:
format: "Fan on - attic: %f - outdoor_min: %f - Sunrise -1°"
args: ['id(${node_name}_temperature).state', 'id(outdoor_min)']
- text_sensor.template.publish:
id: ${node_name}_change_reason
state: !lambda |-
return "Fan on - attic: " + value_accuracy_to_string(id(${node_name}_temperature).state, 1) + " - outdoor_min: " + value_accuracy_to_string(id(outdoor_min), 1) + " - Sunrise -1°";
- elevation: 2°
then:
- fan.turn_off:
id: ${node_name}
- logger.log:
format: "Fan off - attic: %f - outdoor_min: %f - Sunrise +2°"
args: ['id(${node_name}_temperature).state', 'id(outdoor_min)']
- text_sensor.template.publish:
id: ${node_name}_change_reason
state: !lambda |-
return "Fan off - attic: " + value_accuracy_to_string(id(${node_name}_temperature).state, 1) + " - outdoor_min: " + value_accuracy_to_string(id(outdoor_min), 1) + " - Sunrise +2°";
I feel like this might be a bug but I’m not sure how to prove it out… anyone know?