updates
This commit is contained in:
21
packages/button/button_inputs.yaml
Executable file
21
packages/button/button_inputs.yaml
Executable 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"
|
514
packages/button/button_logic.yaml
Executable file
514
packages/button/button_logic.yaml
Executable file
@ -0,0 +1,514 @@
|
||||
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: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.adaptive_lighting_default
|
||||
- service: light.turn_on
|
||||
data:
|
||||
effect: Twitter
|
||||
target:
|
||||
entity_id: light.ceiling
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 1
|
||||
milliseconds: 500
|
||||
- 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: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.adaptive_lighting_default
|
||||
- service: light.turn_on
|
||||
data:
|
||||
effect: Twitter
|
||||
target:
|
||||
entity_id: light.bed_ceiling
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 1
|
||||
milliseconds: 500
|
||||
- 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: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.adaptive_lighting_default
|
||||
- service: light.turn_on
|
||||
data:
|
||||
effect: Twitter
|
||||
target:
|
||||
entity_id: light.all_indirect
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 1
|
||||
milliseconds: 500
|
||||
- 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: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.adaptive_lighting_default
|
||||
- service: light.turn_on
|
||||
data:
|
||||
effect: Twitter
|
||||
target:
|
||||
entity_id: light.all_lights
|
||||
- delay:
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 1
|
||||
milliseconds: 500
|
||||
- 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
|
104
packages/button/button_press.yaml
Executable file
104
packages/button/button_press.yaml
Executable file
@ -0,0 +1,104 @@
|
||||
automation:
|
||||
#----------------------------------------------------------------------------------#
|
||||
# L/R
|
||||
#----------------------------------------------------------------------------------#
|
||||
# Button Left: Pos Left
|
||||
- alias: button_pos_left
|
||||
trigger:
|
||||
# Bed
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 4f9d195bf907da59e1461a5d2404f606
|
||||
type: action
|
||||
subtype: arrow_left_click
|
||||
discovery_id: 0x0c4314fffee0bb44 action_arrow_left_click
|
||||
# Door
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 5e67efdee83ccceaac84046dfc6c735e
|
||||
type: action
|
||||
subtype: arrow_left_click
|
||||
discovery_id: 0x0c4314fffef68790 action_arrow_left_click
|
||||
action:
|
||||
- service: script.pos_left_incr
|
||||
mode: single
|
||||
|
||||
# Button Left: Pos Right
|
||||
- alias: button_pos_right
|
||||
trigger:
|
||||
# Bed
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 4f9d195bf907da59e1461a5d2404f606
|
||||
type: action
|
||||
subtype: arrow_right_click
|
||||
discovery_id: 0x0c4314fffee0bb44 action_arrow_right_click
|
||||
# Door
|
||||
- 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:
|
||||
# Desk
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 121e4230e41feb19254fa92ed5335760
|
||||
type: action
|
||||
subtype: "on"
|
||||
discovery_id: 0x2c1165fffebebf6d action_on
|
||||
# Bed
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 4f9d195bf907da59e1461a5d2404f606
|
||||
type: action
|
||||
subtype: "on"
|
||||
discovery_id: 0x0c4314fffee0bb44 action_on
|
||||
# Door
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 5e67efdee83ccceaac84046dfc6c735e
|
||||
type: action
|
||||
subtype: "on"
|
||||
discovery_id: 0x0c4314fffef68790 action_on
|
||||
action:
|
||||
- service: script.pos_up
|
||||
mode: single
|
||||
# Down
|
||||
- alias: button_down
|
||||
trigger:
|
||||
# Desk
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 121e4230e41feb19254fa92ed5335760
|
||||
type: action
|
||||
subtype: "off"
|
||||
discovery_id: 0x2c1165fffebebf6d action_off
|
||||
# Bed
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 4f9d195bf907da59e1461a5d2404f606
|
||||
type: action
|
||||
subtype: "off"
|
||||
discovery_id: 0x0c4314fffee0bb44 action_off
|
||||
# Door
|
||||
- platform: device
|
||||
domain: mqtt
|
||||
device_id: 5e67efdee83ccceaac84046dfc6c735e
|
||||
type: action
|
||||
subtype: "off"
|
||||
discovery_id: 0x0c4314fffef68790 action_off
|
||||
action:
|
||||
- service: script.pos_down
|
||||
mode: single
|
Reference in New Issue
Block a user