Hi HA enthusiasts and gurus!
I wanted to share my attempt to automate external horizontal shutters
based on luminance sensor. I have them controlled by Shelly 2.5 which after calibration enable to set a % position. I have also created 4 scripts to set them in slightly open at 1, 2, 3 and 4% (to achieve that the shutter has to close completely and open to the desired percentage):
cover_open_1:
alias: Shutters 1%
sequence:
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 0
- wait_template: '{{ is_state(''cover.shellyswitch25_483fda821821'', ''closed'')
}}'
timeout: 00:01:00
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 1
cover_open_2:
alias: Shutters 2%
sequence:
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 0
- wait_template: '{{ is_state(''cover.shellyswitch25_483fda821821'', ''closed'')
}}'
timeout: 00:01:00
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 2
cover_open_3:
alias: Shutters 3%
sequence:
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 0
- wait_template: '{{ is_state(''cover.shellyswitch25_483fda821821'', ''closed'')
}}'
timeout: 00:01:00
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 3
cover_open_4:
alias: Shutters 4%
sequence:
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 0
- wait_template: '{{ is_state(''cover.shellyswitch25_483fda821821'', ''closed'')
}}'
timeout: 00:01:00
- service: cover.set_cover_position
data:
entity_id: cover.shellyswitch25_483fda821821
position: 4
now I’ve put a Xiaomi Luminance sensor on the desk just in front of the window in an attempt to control the position of the shutter depending on the luminance measured:
- id: '1614674730761'
alias: Shutter - above 1400lx
trigger:
- platform: numeric_state
entity_id: sensor.xiaomi_lumi_sen_ill_mgl01_illuminance
above: '1400'
condition:
- condition: numeric_state
entity_id: cover.shellyswitch25_483fda821821
attribute: current_position
above: '1'
- condition: state
entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
state: 'off'
action:
- service: script.cover_open_1
data: {}
mode: single
- id: '1614675625938'
alias: Shutter - below 500lx
trigger:
- platform: numeric_state
entity_id: sensor.xiaomi_lumi_sen_ill_mgl01_illuminance
below: '500'
condition:
- condition: state
entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
state: 'off'
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: cover.shellyswitch25_483fda821821
attribute: current_position
above: '0'
below: '2'
sequence:
- service: script.cover_open_2
data: {}
- conditions:
- condition: numeric_state
entity_id: cover.shellyswitch25_483fda821821
attribute: current_position
above: '1'
below: '3'
sequence:
- service: script.cover_open_3
data: {}
- conditions:
- condition: numeric_state
entity_id: cover.shellyswitch25_483fda821821
attribute: current_position
above: '2'
below: '4'
sequence:
- service: script.cover_open_4
data: {}
default: []
mode: single
Overall, it works well, there are times though when it is frequently opening and closing.This is at times when the sun is covered by clouds and the clouds are on and off. The luminance values were defined experimentally in full sunshine and work well also when the sun is behind the clouds. What would you recommend doing to avoid too frequent opening and closing of the shutters?