Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (24 sloc) 1.05 KB
automation:
##############################################################################
# Set backlight based on sun elevation according to following:
# elevation > 10 == backlight 255
# elevation -10 to 10 == backlight 20 to 255
# elevation below -10 == backlight 20
- alias: hasp_plate01_00_BacklightBySun
trigger:
- platform: time_pattern
# Matches every minute
seconds: 00
condition:
- condition: template
value_template: '{{ states.sun.sun.attributes.elevation <= 10 }}'
- condition: template
value_template: '{{ states.sun.sun.attributes.elevation >= -10 }}'
- condition: state
entity_id: 'binary_sensor.plate01_connected'
state: 'on'
action:
- service: mqtt.publish
data:
topic: 'hasp/plate01/brightness/set'
payload_template: "{% if state_attr('sun.sun', 'elevation') >= 10 -%}255{% elif (state_attr('sun.sun', 'elevation') < 10) and (state_attr('sun.sun', 'elevation') > -10) %}{{ ((state_attr('sun.sun', 'elevation') + 10) * 12.5) | int + 5 }}{% else %}5{%- endif %}"
You can’t perform that action at this time.