globals:
- id: my_global_int
type: float
restore_value: no
initial_value: '0'
- id: my_global_inta
type: double
restore_value: no
initial_value: '150'
- id: my_global_intc
type: float
restore_value: no
initial_value: '2'
binary_sensor:
- platform: gpio
name: "MCP23017 Pin #1"
pin:
number: 25
inverted: True
mode: INPUT_PULLUP
internal: true
id: my_binary_sensor
on_double_click:
min_length: 50ms
max_length: 500ms
then:
- while:
condition:
- binary_sensor.is_on: my_binary_sensor
then:
- while:
condition:
- binary_sensor.is_on: my_binary_sensor
- lambda: |-
return (id(my_global_inta) >= 150) && (id(my_global_inta) < 400);
then:
- light.turn_on:
id: lights_1
transition_length: 0.1s
color_temperature: !lambda |-
id(my_global_inta) += 5;
return id(my_global_inta);
- delay: 0.1s
- while:
condition:
- binary_sensor.is_on: my_binary_sensor
- lambda: |-
return (id(my_global_inta) > 150) && (id(my_global_inta) <= 400);
then:
- light.turn_on:
id: lights_1
transition_length: 0.1s
color_temperature: !lambda |-
id(my_global_inta) -= 5;
return id(my_global_inta);
- delay: 0.1s
on_press:
- delay: 0.55s
- if:
condition:
- binary_sensor.is_on: my_binary_sensor
then:
- while:
condition:
- binary_sensor.is_on: my_binary_sensor
then:
- while:
condition:
- binary_sensor.is_on: my_binary_sensor
- lambda: |-
return (id(my_global_int) >= 0) && (id(my_global_int) < 50);
then:
- light.dim_relative:
id: lights_1
relative_brightness: !lambda |-
id(my_global_int) += 1;
return id(my_global_intc) / 100.0;
transition_length: 0.3s
- delay: 0.1s
- while:
condition:
- binary_sensor.is_on: my_binary_sensor
- lambda: |-
return (id(my_global_int) > 0) && (id(my_global_int) <= 50);
then:
- light.dim_relative:
id: lights_1
relative_brightness: !lambda |-
id(my_global_int) -= 1;
return id(my_global_intc) / -100.0;
transition_length: 0.2s
- delay: 0.1s
else:
- light.toggle: lights_1
|