Button Light Menu

This commit is contained in:
darthsandmann 2022-08-07 20:10:43 +02:00
parent 6b07c3b488
commit d7fedcd96b
11 changed files with 631 additions and 94 deletions

View File

@ -1,7 +1,60 @@
#- type: 'custom:button-card' #- type: 'custom:button-card'
# template: card_title # template: card_title
# name: Lights # name: Lights
- type: "horizontal-stack"
cards:
- type: 'custom:button-card'
template: card_script
variables:
ulm_card_script_title: Left Incr
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.pos_left_incr
- type: 'custom:button-card'
template: card_script
variables:
ulm_card_script_title: Right Incr
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.pos_right_incr
- type: "horizontal-stack"
cards:
- type: 'custom:button-card'
template: card_script
variables:
ulm_card_script_title: Up
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.pos_up
- type: 'custom:button-card'
template: card_script
variables:
ulm_card_script_title: Down
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.pos_down
- type: "horizontal-stack"
cards:
- type: 'custom:button-card'
template: card_generic
entity: input_number.pos_left
- type: 'custom:button-card'
template: card_generic
entity: input_number.pos_right
- type: 'custom:button-card'
template: card_generic
entity: timer.pos_timer
- type: "horizontal-stack" - type: "horizontal-stack"
cards: cards:

View File

@ -17,10 +17,10 @@
name: "Adaptive" name: "Adaptive"
bg_color: "yellow" bg_color: "yellow"
entity_2: entity_2:
entity_id: scene.light_blue entity_id: scene.light_bright
icon: "mdi:television-play" icon: "mdi:television-play"
icon_color: "blue" icon_color: "blue"
name: "Blue" name: "Bright"
bg_color: "blue" bg_color: "blue"
entity_3: entity_3:
entity_id: "scene.light_night" entity_id: "scene.light_night"

View File

@ -0,0 +1,21 @@
input_number:
pos_left:
name: Pos Left
initial: 0
step: 1
min: 0
max: 4
mode: box
pos_right:
name: Pos Right
initial: 0
step: 1
min: 0
max: 9
mode: box
timer:
pos_timer:
duration: "00:00:10"

View File

@ -0,0 +1,446 @@
script:
#----------------------------------------------------------------------------------#
# L/R
#----------------------------------------------------------------------------------#
# 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: 0
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: 0
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/Down
#----------------------------------------------------------------------------------#
# 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:
- 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
# 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
# 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
# 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
# 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
# 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
# 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
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:
- 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
# 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
# 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
# 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: script.light_ceiling_save
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- service: light.turn_on
data:
effect: Twitter
target:
entity_id: light.ceiling
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: script.light_ceiling_restore
# 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: script.light_ceiling_bed_save
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- service: light.turn_on
data:
effect: Twitter
target:
entity_id: light.bed_ceiling
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: script.light_ceiling_bed_restore
# 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: script.light_indirect_save
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- service: light.turn_on
data:
effect: Twitter
target:
entity_id: light.all_indirect
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: script.light_indirect_restore
# 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: script.light_store_save
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- service: light.turn_on
data:
effect: Twitter
target:
entity_id: light.all_lights
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: script.light_store_restore
# 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
# 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
# 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

View File

@ -1,31 +1,51 @@
automation: automation:
- alias: button_on #----------------------------------------------------------------------------------#
# L/R
#----------------------------------------------------------------------------------#
# Button Left: Pos Left
- alias: button_pos_left
trigger: trigger:
- platform: device - platform: device
domain: mqtt domain: mqtt
device_id: 121e4230e41feb19254fa92ed5335760 device_id: 4f9d195bf907da59e1461a5d2404f606
type: action type: action
subtype: 'on' subtype: arrow_left_click
discovery_id: 0x2c1165fffebebf6d action_on discovery_id: 0x0c4314fffee0bb44 action_arrow_left_click
- platform: device - platform: device
domain: mqtt domain: mqtt
device_id: 4f9d195bf907da59e1461a5d2404f606 device_id: 5e67efdee83ccceaac84046dfc6c735e
type: action type: action
subtype: "on" subtype: arrow_left_click
discovery_id: 0x0c4314fffee0bb44 action_on discovery_id: 0x0c4314fffef68790 action_arrow_left_click
- platform: device
domain: mqtt
device_id: 5e67efdee83ccceaac84046dfc6c735e
type: action
subtype: "on"
discovery_id: 0x0c4314fffef68790 action_on
action: action:
- service: scene.turn_on - service: script.pos_left_incr
target:
entity_id: scene.light_adaptive
mode: single mode: single
- alias: button_off # Button Left: Pos Right
- alias: button_pos_right
trigger:
- platform: device
domain: mqtt
device_id: 4f9d195bf907da59e1461a5d2404f606
type: action
subtype: arrow_right_click
discovery_id: 0x0c4314fffee0bb44 action_arrow_right_click
- platform: device
domain: mqtt
device_id: 5e67efdee83ccceaac84046dfc6c735e
type: action
subtype: arrow_left_click
discovery_id: 0x0c4314fffef68790 action_arrow_right_click
action:
- service: script.pos_right_incr
mode: single
#----------------------------------------------------------------------------------#
# Up/Down
#----------------------------------------------------------------------------------#
# Up
- alias: button_up
trigger: trigger:
- platform: device - platform: device
domain: mqtt domain: mqtt
@ -46,50 +66,10 @@ automation:
subtype: "on" subtype: "on"
discovery_id: 0x0c4314fffef68790 action_on discovery_id: 0x0c4314fffef68790 action_on
action: action:
- service: script.light_store_off - service: script.pos_up
mode: single mode: single
# Down
- alias: button_ceiling_on - alias: button_down
trigger:
- platform: device
domain: mqtt
device_id: 4f9d195bf907da59e1461a5d2404f606
type: action
subtype: arrow_left_click
discovery_id: 0x0c4314fffee0bb44 action_arrow_left_click
- platform: device
domain: mqtt
device_id: 5e67efdee83ccceaac84046dfc6c735e
type: action
subtype: arrow_left_click
discovery_id: 0x0c4314fffef68790 action_arrow_left_click
action:
- service: light.toggle
target:
entity_id: light.ceiling
mode: single
- alias: button_ceiling_bed_on
trigger:
- platform: device
domain: mqtt
device_id: 4f9d195bf907da59e1461a5d2404f606
type: action
subtype: arrow_right_click
discovery_id: 0x0c4314fffee0bb44 action_arrow_right_click
- platform: device
domain: mqtt
device_id: 5e67efdee83ccceaac84046dfc6c735e
type: action
subtype: arrow_right_click
discovery_id: 0x0c4314fffef68790 action_arrow_right_click
action:
- service: light.toggle
target:
device_id: 2f01ed8d8c56ffea9ab769ba3cf527d9
mode: single
- alias: button_sleep
trigger: trigger:
- platform: device - platform: device
domain: mqtt domain: mqtt
@ -110,7 +90,5 @@ automation:
subtype: "off" subtype: "off"
discovery_id: 0x0c4314fffef68790 action_off discovery_id: 0x0c4314fffef68790 action_off
action: action:
- service: switch.toggle - service: script.pos_down
target:
entity_id: switch.adaptive_lighting_sleep_mode_default
mode: single mode: single

View File

@ -1,13 +0,0 @@
# script:
# indirect_brightness_increase:
# sequence:
# - service: light.turn_on
# entity_id: light.indirect
# data_template:
# brightness: >
# {% set incr = 10 %}
# {% set current = (state_attr('light.indirect', 'brightness') | int) %}
# {% set new = current | int + incr %}
# {% if new > 255 %} 255
# {% else %} {{ new_brightness }}
# {% endif %}

View File

@ -1,5 +1,5 @@
homekit: homekit:
ip_address: 10.10.10.50 ip_address: 10.10.20.50
filter: filter:
include_entities: include_entities:

View File

@ -23,3 +23,12 @@ scene:
state: true state: true
brightness: 1 brightness: 1
switch.adaptive_lighting_sleep_mode_default: on switch.adaptive_lighting_sleep_mode_default: on
- name: light_bright
entities:
switch.adaptive_lighting_default: off
light.all_direct: false
light.all_lights:
color_temp: 238
state: true
brightness: 255
switch.adaptive_lighting_sleep_mode_default: off

View File

@ -26,3 +26,45 @@ script:
store_name: flash_store store_name: flash_store
operation: restore operation: restore
light_ceiling_save:
sequence:
- service: python_script.light_store
data:
store_name: ceiling_store
entity_id:
- light.ceiling
light_ceiling_restore:
sequence:
- service: python_script.light_store
data:
store_name: ceiling_store
operation: restore
light_ceiling_bed_save:
sequence:
- service: python_script.light_store
data:
store_name: ceiling_store
entity_id:
- light.bed_ceiling
light_ceiling_bed_restore:
sequence:
- service: python_script.light_store
data:
store_name: ceiling_store
operation: restore
light_indirect_save:
sequence:
- service: python_script.light_store
data:
store_name: ceiling_store
entity_id:
- light.all_indirect
light_indirect_restore:
sequence:
- service: python_script.light_store
data:
store_name: ceiling_store
operation: restore

View File

@ -19,28 +19,28 @@ yeelight:
10.10.10.82: 10.10.10.82:
name: ceiling1 name: ceiling1
save_on_change: False save_on_change: False
transition: 1000 transition: 500
10.10.10.83: 10.10.10.83:
name: ceiling2 name: ceiling2
save_on_change: False save_on_change: False
transition: 1000 transition: 500
10.10.10.80: 10.10.10.80:
name: ceiling3 name: ceiling3
save_on_change: False save_on_change: False
transition: 1000 transition: 500
10.10.10.81: 10.10.10.81:
name: bed_ceiling name: bed_ceiling
save_on_change: False save_on_change: False
transition: 1000 transition: 500
10.10.10.84: 10.10.10.84:
name: bed name: bed
save_on_change: False save_on_change: False
transition: 1000 transition: 500
model: strip1 model: strip1
10.10.10.85: 10.10.10.85:
name: desk name: desk
save_on_change: False save_on_change: False
transition: 1000 transition: 500
model: strip1 model: strip1

1
scripts.yaml Normal file
View File

@ -0,0 +1 @@