script: #----------------------------------------------------------------------------------# # Left #----------------------------------------------------------------------------------# pos_left_incr: alias: pos_left_incr sequence: - if: - condition: numeric_state entity_id: input_number.pos_right above: '0' then: - service: input_number.set_value data: value: 0 target: entity_id: input_number.pos_right else: - if: - condition: numeric_state entity_id: input_number.pos_left above: '3' then: - service: input_number.set_value data: value: 1 target: entity_id: input_number.pos_left else: - service: input_number.increment target: entity_id: input_number.pos_left # Restart/Start the timer - service: timer.cancel target: entity_id: timer.pos_timer - service: timer.start target: entity_id: timer.pos_timer mode: single #----------------------------------------------------------------------------------# # Right #----------------------------------------------------------------------------------# pos_right_incr: alias: pos_right_incr sequence: - if: - condition: numeric_state entity_id: input_number.pos_left above: '0' then: - service: input_number.set_value data: value: 0 target: entity_id: input_number.pos_left else: - if: - condition: numeric_state entity_id: input_number.pos_right above: '2' then: - service: input_number.set_value data: value: 1 target: entity_id: input_number.pos_right else: - service: input_number.increment target: entity_id: input_number.pos_right # Restart/Start the timer - service: timer.cancel target: entity_id: timer.pos_timer - service: timer.start target: entity_id: timer.pos_timer mode: single #----------------------------------------------------------------------------------# # Up #----------------------------------------------------------------------------------# pos_up: alias: pos_up sequence: # 0,0 - if: - condition: and conditions: - condition: state entity_id: input_number.pos_left state: "0.0" - condition: state entity_id: input_number.pos_right state: "0.0" then: - if: - condition: - condition: state entity_id: light.all_lights state: "on" then: - service: script.summary_notification else: - service: scene.turn_on target: entity_id: scene.snapshot_all #- service: light.turn_on # target: # entity_id: light.all_lights # 1,0 Ceiling - if: - condition: - condition: state entity_id: input_number.pos_left state: "1.0" then: - service: light.turn_on target: entity_id: light.ceiling - service: automation.trigger target: entity_id: automation.light_all_snapshot # 2,0 Bed - if: - condition: - condition: state entity_id: input_number.pos_left state: "2.0" then: - service: light.turn_on target: entity_id: light.bed_ceiling - service: automation.trigger target: entity_id: automation.light_all_snapshot # 3,0 Indirect - if: - condition: - condition: state entity_id: input_number.pos_left state: "3.0" then: - service: light.turn_on target: entity_id: light.all_indirect - service: automation.trigger target: entity_id: automation.light_all_snapshot # 4,0 All Lights - if: - condition: - condition: state entity_id: input_number.pos_left state: "4.0" then: - service: light.turn_on target: entity_id: light.all_lights - service: automation.trigger target: entity_id: automation.light_all_snapshot # 0,1 Adaptive - if: - condition: - condition: state entity_id: input_number.pos_right state: "1.0" then: - service: scene.turn_on target: entity_id: scene.light_adaptive - service: automation.trigger target: entity_id: automation.light_all_snapshot # 0,2 Night - if: - condition: - condition: state entity_id: input_number.pos_right state: "2.0" then: - service: scene.turn_on target: entity_id: scene.light_night - service: automation.trigger target: entity_id: automation.light_all_snapshot # 0,3 Bright - if: - condition: - condition: state entity_id: input_number.pos_right state: "3.0" then: - service: scene.turn_on target: entity_id: scene.light_bright - service: automation.trigger target: entity_id: automation.light_all_snapshot mode: single #----------------------------------------------------------------------------------# # Down #----------------------------------------------------------------------------------# pos_down: alias: pos_down sequence: # 0,0 - if: - condition: and conditions: - condition: state entity_id: input_number.pos_left state: "0.0" - condition: state entity_id: input_number.pos_right state: "0.0" then: - if: - condition: - condition: state entity_id: light.all_lights state: "off" then: - service: script.summary_notification else: - service: light.turn_off target: entity_id: light.all_lights # 1,0 Ceiling - if: - condition: - condition: state entity_id: input_number.pos_left state: "1.0" then: - service: light.turn_off target: entity_id: light.ceiling - service: automation.trigger target: entity_id: automation.light_all_snapshot # 2,0 Bed - if: - condition: - condition: state entity_id: input_number.pos_left state: "2.0" then: - service: light.turn_off target: entity_id: light.bed_ceiling - service: automation.trigger target: entity_id: automation.light_all_snapshot # 3,0 Indirect - if: - condition: - condition: state entity_id: input_number.pos_left state: "3.0" then: - service: light.turn_off target: entity_id: light.all_indirect - service: automation.trigger target: entity_id: automation.light_all_snapshot # 4,0 All Lights - if: - condition: - condition: state entity_id: input_number.pos_left state: "4.0" then: - service: light.turn_off target: entity_id: light.all_lights mode: single #----------------------------------------------------------------------------------# # Dimming #----------------------------------------------------------------------------------# button_brightness_up: sequence: - service: light.turn_on data_template: entity_id: light.direct brightness: >- {% set current = states.light.direct.attributes.brightness|default(0)|int %} {% set step = 100 %} {% set next = current + step %} {% if next > 255 %} {% set next = 255 %} {% endif %} {{ next }} - delay: milliseconds: 1 - service: script.turn_on data: entity_id: script.button_brightness_up_loop button_brightness_up_loop: sequence: - service: script.turn_on data: entity_id: script.button_brightness_up button_brightness_down: sequence: - service: light.turn_on data_template: entity_id: light.direct brightness: >- {% set current = states.light.direct.attributes.brightness|default(0)|int %} {% set step = 100 %} {% set next = current - step %} {% if next < 1 %} {% set next = 1 %} {% endif %} {{ next }} - delay: milliseconds: 1 - service: script.turn_on data: entity_id: script.button_brightness_down_loop button_brightness_down_loop: sequence: - service: script.turn_on data: entity_id: script.button_brightness_down #------------------------------------------------------------------------------------# # Automations #------------------------------------------------------------------------------------# automation: # Timer - alias: pos_timer_reset mode: single trigger: - platform: event event_type: timer.finished event_data: entity_id: timer.pos_timer action: - service: input_number.set_value data: value: 0 target: entity_id: - input_number.pos_left - input_number.pos_right # Pos 1,0 Ceiling - alias: pos_1_0_flash mode: single trigger: - platform: state entity_id: - input_number.pos_left to: "1.0" action: - service: automation.trigger target: entity_id: automation.light_all_snapshot - service: light.turn_on data: effect: Twitter target: entity_id: light.ceiling - delay: hours: 0 minutes: 0 seconds: 1 milliseconds: 0 - service: scene.turn_on target: entity_id: scene.snapshot_all # Pos 2,0 Ceiling Bed - alias: pos_2_0_flash mode: single trigger: - platform: state entity_id: - input_number.pos_left to: "2.0" action: - service: automation.trigger target: entity_id: automation.light_all_snapshot - service: light.turn_on data: effect: Twitter target: entity_id: light.bed_ceiling - delay: hours: 0 minutes: 0 seconds: 1 milliseconds: 0 - service: scene.turn_on target: entity_id: scene.snapshot_all # Pos 3,0 Indirect - alias: pos_3_0_flash mode: single trigger: - platform: state entity_id: - input_number.pos_left to: "3.0" action: - service: automation.trigger target: entity_id: automation.light_all_snapshot - service: light.turn_on data: effect: Twitter target: entity_id: light.all_indirect - delay: hours: 0 minutes: 0 seconds: 1 milliseconds: 0 - service: scene.turn_on target: entity_id: scene.snapshot_all # Pos 4,0 All Lights - alias: pos_4_0_flash mode: single trigger: - platform: state entity_id: - input_number.pos_left to: "4.0" action: - service: automation.trigger target: entity_id: automation.light_all_snapshot - service: light.turn_on data: effect: Twitter target: entity_id: light.all_lights - delay: hours: 0 minutes: 0 seconds: 1 milliseconds: 0 - service: scene.turn_on target: entity_id: scene.snapshot_all # Pos 0,1 Adaptive - alias: pos_0_1_flash mode: single trigger: - platform: state entity_id: - input_number.pos_right to: "1.0" action: - service: scene.turn_on target: entity_id: scene.light_adaptive - service: automation.trigger target: entity_id: automation.light_all_snapshot # Pos 0,2 - alias: pos_0_2_flash mode: single trigger: - platform: state entity_id: - input_number.pos_right to: "2.0" action: - service: scene.turn_on target: entity_id: scene.light_night - service: automation.trigger target: entity_id: automation.light_all_snapshot # Pos 0,3 - alias: pos_0_3_flash mode: single trigger: - platform: state entity_id: - input_number.pos_right to: "3.0" action: - service: scene.turn_on target: entity_id: scene.light_bright - service: automation.trigger target: entity_id: automation.light_all_snapshot