Just looking for a code check here. Trying to make a binary sensor that turns on as follows:
30 min from sunset & > 30% cloudy
or
sun elevation = -5
Does this look right?
- platform: template
sensors:
time_logic:
value_template: >-
"{{ states('sensor.owm_cloud_coverage')| float >= 30
and states('sensor.time') == as_timestamp(state_attr('sun.sun', 'next_setting')) | timestamp_custom('%R')
or state_attr('sun.sun', 'elevation') | float <=-5}}"
2 posts - 2 participants