diff --git a/automations.yaml b/automations.yaml index c3818e3..0b13141 100644 --- a/automations.yaml +++ b/automations.yaml @@ -874,21 +874,30 @@ dimmer_device: ccc672e3d924e72a952d801736ea59d3 on_short_action: [] on_long_action: + - service: switch.turn_on + data: {} + target: + entity_id: switch.adaptive_lighting_adapt_brightness_living_room + - wait_template: '{{ is_state(''switch.adaptive_lighting_adapt_brightness_living_room'',''on'') + }}' + continue_on_timeout: true + timeout: 00:00:05 - service: input_select.select_option data: option: Adaptive target: entity_id: input_select.living_room_scenes - brightness_up_short_action: + - delay: + hours: 0 + minutes: 0 + seconds: 3 + milliseconds: 0 - service: switch.turn_off data: {} target: - entity_id: switch.adaptive_lighting_living_room - brightness_down_short_action: - - service: switch.turn_off - data: {} - target: - entity_id: switch.adaptive_lighting_living_room + entity_id: switch.adaptive_lighting_adapt_brightness_living_room + brightness_up_short_action: [] + brightness_down_short_action: [] off_short_action: - service: input_boolean.turn_on data: {} @@ -899,16 +908,8 @@ option: Tokyo target: entity_id: input_select.living_room_scenes - brightness_up_long_action: - - service: switch.turn_off - data: {} - target: - entity_id: switch.adaptive_lighting_living_room - brightness_down_long_action: - - service: switch.turn_off - data: {} - target: - entity_id: switch.adaptive_lighting_living_room + brightness_up_long_action: [] + brightness_down_long_action: [] off_long_action: - service: light.turn_on data: {} @@ -923,6 +924,26 @@ data: option: Adaptive target: - entity_id: - - input_select.living_room_scenes - - input_select.dining_room_lamp_scenes + entity_id: input_select.dining_room_lamp_scenes + - service: switch.turn_on + data: {} + target: + entity_id: switch.adaptive_lighting_adapt_brightness_living_room + - wait_template: '{{ is_state(''switch.adaptive_lighting_adapt_brightness_living_room'',''on'') + }}' + continue_on_timeout: true + timeout: 00:00:05 + - service: input_select.select_option + data: + option: Adaptive + target: + entity_id: input_select.living_room_scenes + - delay: + hours: 0 + minutes: 0 + seconds: 3 + milliseconds: 0 + - service: switch.turn_off + data: {} + target: + entity_id: switch.adaptive_lighting_adapt_brightness_living_room diff --git a/packages/lighting_and_scenes.yaml b/packages/lighting_and_scenes.yaml index 2b2f4e1..5dc0765 100644 --- a/packages/lighting_and_scenes.yaml +++ b/packages/lighting_and_scenes.yaml @@ -347,6 +347,87 @@ sensor: {% endif %} unit_of_measurement: 'K' icon_template: mdi:thermometer-lines + living_room_lights_brightness_actual: + friendly_name: "Living Room Lights - Brightness Actual" + unique_id: e557022a-184f-4111-bb6a-6c0869cce42c + value_template: > + {% set current = state_attr('light.living_room_lights','brightness') %} + {{ ((current / 255) * 100) | float | round(2) }} + availability_template: > + {% if is_state('light.living_room_lights','on') %} + true + {% else %} + false + {% endif %} + unit_of_measurement: '%' + icon_template: mdi:brightness-percent + living_room_lights_brightness_intended: + friendly_name: "Living Room Lights - Brightness Intended" + unique_id: a758742f-6724-4920-a9d1-325fe4f02664 + value_template: "{{ state_attr('switch.adaptive_lighting_living_room','brightness_pct') | float | round(2) }}" + availability_template: > + {% if is_state('switch.adaptive_lighting_living_room','on') %} + true + {% else %} + false + {% endif %} + unit_of_measurement: '%' + icon_template: mdi:brightness-percent + living_room_lights_colortemp_actual: + friendly_name: "Living Room Lights - Colortemp Actual" + unique_id: dbe08826-e113-4474-bbca-60d3c32a4b65 + value_template: "{{ state_attr('light.living_room_lights','color_temp_kelvin') | int }}" + availability_template: > + {% if is_state('light.living_room_lights','on') %} + true + {% else %} + false + {% endif %} + unit_of_measurement: 'K' + icon_template: mdi:thermometer-lines + living_room_lights_colortemp_intended: + friendly_name: "Living Room Lights - Colortemp Intended" + unique_id: 8b974c03-ab5b-4b89-97bf-afee78fa1a40 + value_template: "{{ state_attr('switch.adaptive_lighting_living_room','color_temp_kelvin') | int }}" + availability_template: > + {% if is_state('switch.adaptive_lighting_living_room','on') %} + true + {% else %} + false + {% endif %} + unit_of_measurement: 'K' + icon_template: mdi:thermometer-lines + living_room_lights_brightness_diff: + friendly_name: "Living Room Lights - Brightness Diff" + unique_id: 05f911d3-3b6a-4ca2-8181-5365707b2456 + value_template: > + {% set current = states('sensor.living_room_lights_brightness_actual') | float %} + {% set intended = states('sensor.living_room_lights_brightness_intended') | float %} + {{ (current - intended) | float | round(2) }} + availability_template: > + {% if is_state('light.living_room_lights','on') and is_state('switch.adaptive_lighting_living_room','on') %} + true + {% else %} + false + {% endif %} + unit_of_measurement: '%' + icon_template: mdi:brightness-percent + living_room_lights_colortemp_diff: + friendly_name: "Living Room Lights - Colortemp Diff" + unique_id: d8fcaa26-d3dc-48d8-b4b9-9e701a1506a8 + value_template: > + {% set current = states('sensor.living_room_lights_colortemp_actual') | float %} + {% set intended = states('sensor.living_room_lights_colortemp_intended') | float %} + {{ (current - intended) | float | round(2) }} + availability_template: > + {% if is_state('light.living_room_lights','on') and is_state('switch.adaptive_lighting_living_room','on') %} + true + {% else %} + false + {% endif %} + unit_of_measurement: 'K' + icon_template: mdi:thermometer-lines + template: - binary_sensor: @@ -399,6 +480,53 @@ template: {% endif %} device_class: problem delay_on: "00:00:10" + - name: Living Room Sync Issue + unique_id: 35b3ca4f-14fb-4564-ab0c-1bb6a829c202 + state: > + {% set colortemp = states('sensor.living_room_lights_colortemp_diff') | float(0) %} + {% set brightness = states('sensor.living_room_lights_brightness_diff') | float(0) %} + {% if is_state('light.living_room_lights','on') %} + {% if is_state('switch.adaptive_lighting_living_room','on') and is_state('switch.adaptive_lighting_sleep_mode_living_room','off') %} + {% if is_state('switch.adaptive_lighting_adapt_brightness_living_room','on') and is_state('switch.adaptive_lighting_adapt_color_living_room','on') %} + {{ (colortemp > 100 or colortemp < -100) or (brightness > 5 or brightness < -5) }} + {% elif is_state('switch.adaptive_lighting_adapt_brightness_living_room','on') and is_state('switch.adaptive_lighting_adapt_color_living_room','off') %} + {{ brightness > 5 or brightness < -5 }} + {% elif is_state('switch.adaptive_lighting_adapt_color_living_room','on') and is_state('switch.adaptive_lighting_adapt_brightness_living_room','off') %} + {{ colortemp > 100 or colortemp < -100 }} + {% endif %} + {% endif %} + {% endif %} + attributes: + color_diff: > + {% set colortemp = states('sensor.living_room_lights_colortemp_diff') | float(0) %} + {% if is_state('light.living_room_lights','on') %} + {% if is_state('switch.adaptive_lighting_living_room','on') and is_state('switch.adaptive_lighting_sleep_mode_living_room','off') %} + {% if is_state('switch.adaptive_lighting_adapt_color_living_room','on') %} + {{ states('sensor.living_room_lights_colortemp_diff') }} + {% else %} + Color Off + {% endif %} + {% else %} + Adaptive Off + {% endif %} + {% else %} + Lights Off + {% endif %} + brightness_diff: > + {% set brightness = states('sensor.living_room_lights_brightness_diff') | float(0) %} + {% if is_state('light.living_room_lights','on') %} + {% if is_state('switch.adaptive_lighting_living_room','on') and is_state('switch.adaptive_lighting_sleep_mode_living_room','off') %} + {% if is_state('switch.adaptive_lighting_adapt_brightness_living_room','on') %} + {{ states('sensor.living_room_lights_brightness_diff') }} + {% else %} + Brightness Off + {% endif %} + {% else %} + Adaptive Off + {% endif %} + {% else %} + Lights Off + {% endif %} device_class: problem delay_on: "00:00:10" @@ -847,6 +975,25 @@ automation: data: option: Adaptive + - id: 3f05cd0d-bd6e-42c7-884d-3d1cbfda46e0 + alias: Living Room Lights Adaptive Resync + description: Deals with situations where the living room lights should be adaptive but end up out of sync + mode: restart + trigger: + - platform: state + entity_id: binary_sensor.living_room_sync_issue + from: 'off' + to: 'on' + condition: + - condition: template + value_template: "{{ is_state_attr('light.living_room_lights','color_mode','color_temp') }}" + action: + - service: input_select.select_option + target: + entity_id: input_select.living_room_scenes + data: + option: Adaptive + script: adaptive_on_first_floor: alias: Adaptive on First Floor