Open dannytsang opened 1 year ago
Using a template sensor to achieve this. Most flexibility for conditions and visibility of each condition. The down side is any changes require a restart to take effect.
Example:
- trigger:
- platform: state
entity_id:
- binary_sensor.bedroom_tv_powered_on
- binary_sensor.bedroom_window
- input_number.close_blinds_brightness_threshold
- input_number.forecast_high_temperature
- sensor.bedroom_tv_power_meter
- sensor.front_garden_motion_light_level
- sun.sun
- weather.home_hourly
binary_sensor:
- name: Bedroom Blind Anticipated State
unique_id: 978fb6f0-42db-4c71-ab13-9037e82da73a
device_class: opening
state: >-
{{ not(states('sensor.front_garden_motion_light_level')|float(0) < states('input_number.close_blinds_brightness_threshold')|float(10000)
and not(states('sun.sun') == 'above_horizon')
and states('binary_sensor.bedroom_window') == 'off')
and state_attr('weather.home_hourly', 'temperature')|float(0) > states('input_number.forecast_high_temperature')|float(24)
and states('binary_sensor.bedroom_tv_powered_on') == 'on'
and not(states('weather.home_hourly') in ['sunny','partlycloudy']) }}
attributes:
brightness: "{{ (states('sensor.front_garden_motion_light_level')|float(0)) < (states('input_number.close_blinds_brightness_threshold')|float(10000)) }}"
sun: "{{ states('sun.sun') == 'above_horizon' }}"
temperature_hour_forecast: "{{ states('weather.home_hourly')|float(0) > states('input_number.forecast_high_temperature')|float(24) }}"
tv_running: "{{ states('binary_sensor.bedroom_tv_powered_on')|default('off') == 'on' }}"
weather: "{{ states('home_hourly')|default('') in ['sunny','partlycloudy'] }}"
window: "{{ states('binary_sensor.bedroom_window') == 'off' }}"
There are multiple conditions to when a window covering should open or close. They exist as separate automations which has multiple issues:
Background The problem was very obvious when #48 was introduced and people in the house were confused why the blind/curtain was open or closed. Before, it used to be based on time and window state.