|
@@ -74,22 +74,30 @@ binary_sensor:
|
|
|
- platform: status
|
|
- platform: status
|
|
|
name: Status
|
|
name: Status
|
|
|
entity_category: diagnostic
|
|
entity_category: diagnostic
|
|
|
-
|
|
|
|
|
- platform: gpio
|
|
- platform: gpio
|
|
|
pin:
|
|
pin:
|
|
|
number: P7
|
|
number: P7
|
|
|
|
|
+ inverted: true
|
|
|
mode:
|
|
mode:
|
|
|
input: true
|
|
input: true
|
|
|
pullup: true
|
|
pullup: true
|
|
|
- inverted: true
|
|
|
|
|
name: "Power Button"
|
|
name: "Power Button"
|
|
|
on_press:
|
|
on_press:
|
|
|
- - switch.toggle: relay
|
|
|
|
|
|
|
+ # - output.toggle: relay
|
|
|
- select.next:
|
|
- select.next:
|
|
|
- id: mode
|
|
|
|
|
|
|
+ id: light_mode
|
|
|
cycle: true
|
|
cycle: true
|
|
|
|
|
|
|
|
-switch:
|
|
|
|
|
|
|
+light:
|
|
|
|
|
+ - platform: binary
|
|
|
|
|
+ name: Red LED
|
|
|
|
|
+ id: red_led
|
|
|
|
|
+ output: led_1
|
|
|
|
|
+ internal: True
|
|
|
|
|
+ restore_mode: ALWAYS_OFF
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+output:
|
|
|
- platform: gpio
|
|
- platform: gpio
|
|
|
# RED
|
|
# RED
|
|
|
id: led_1
|
|
id: led_1
|
|
@@ -97,27 +105,13 @@ switch:
|
|
|
number: P6
|
|
number: P6
|
|
|
inverted: false
|
|
inverted: false
|
|
|
|
|
|
|
|
- - platform: gpio
|
|
|
|
|
- # BLUE
|
|
|
|
|
- id: led_2
|
|
|
|
|
- pin:
|
|
|
|
|
- number: P26
|
|
|
|
|
- inverted: false
|
|
|
|
|
-
|
|
|
|
|
- - platform: gpio
|
|
|
|
|
- pin: P8
|
|
|
|
|
- id: relay
|
|
|
|
|
- internal: true
|
|
|
|
|
-
|
|
|
|
|
- # Turn off red LED to show blue when turned on
|
|
|
|
|
- on_turn_on:
|
|
|
|
|
- - switch.turn_on: led_2
|
|
|
|
|
- - switch.turn_off: led_1
|
|
|
|
|
-
|
|
|
|
|
- # Turns on the red LED once the plug is turned off
|
|
|
|
|
- on_turn_off:
|
|
|
|
|
- - switch.turn_off: led_2
|
|
|
|
|
- - switch.turn_on: led_1
|
|
|
|
|
|
|
+# - platform: gpio
|
|
|
|
|
+# # BLUE
|
|
|
|
|
+# id: led_2
|
|
|
|
|
+status_led:
|
|
|
|
|
+ pin:
|
|
|
|
|
+ number: P26
|
|
|
|
|
+ inverted: false
|
|
|
|
|
|
|
|
button:
|
|
button:
|
|
|
- platform: restart
|
|
- platform: restart
|
|
@@ -125,35 +119,33 @@ button:
|
|
|
name: Restart
|
|
name: Restart
|
|
|
entity_category: diagnostic
|
|
entity_category: diagnostic
|
|
|
|
|
|
|
|
-
|
|
|
|
|
globals:
|
|
globals:
|
|
|
- - id: current_light
|
|
|
|
|
- type: select
|
|
|
|
|
- restore_value: True
|
|
|
|
|
- initial_value: "0"
|
|
|
|
|
|
|
+ - id: current_light
|
|
|
|
|
+ type: int
|
|
|
|
|
+ initial_value: "0"
|
|
|
|
|
|
|
|
select:
|
|
select:
|
|
|
- platform: template
|
|
- platform: template
|
|
|
name: "Light Mode"
|
|
name: "Light Mode"
|
|
|
- id: mode
|
|
|
|
|
|
|
+ id: light_mode
|
|
|
options:
|
|
options:
|
|
|
- "Off"
|
|
- "Off"
|
|
|
- "Day"
|
|
- "Day"
|
|
|
- - Daybreak
|
|
|
|
|
- - Night
|
|
|
|
|
|
|
+ - "Daybreak"
|
|
|
|
|
+ - "Night"
|
|
|
optimistic: true
|
|
optimistic: true
|
|
|
on_value:
|
|
on_value:
|
|
|
then:
|
|
then:
|
|
|
- if:
|
|
- if:
|
|
|
condition:
|
|
condition:
|
|
|
- lambda: |-
|
|
- lambda: |-
|
|
|
- return(id(mode).state) == "Off";
|
|
|
|
|
|
|
+ return(id(light_mode).state) == "Off";
|
|
|
then:
|
|
then:
|
|
|
- switch.turn_off: relay
|
|
- switch.turn_off: relay
|
|
|
- if:
|
|
- if:
|
|
|
condition:
|
|
condition:
|
|
|
- lambda: |-
|
|
- lambda: |-
|
|
|
- return(id(mode).state) == "Day";
|
|
|
|
|
|
|
+ return(id(light_mode).state) == "Day";
|
|
|
then:
|
|
then:
|
|
|
- switch.turn_off: relay
|
|
- switch.turn_off: relay
|
|
|
- delay: 20s
|
|
- delay: 20s
|
|
@@ -161,7 +153,7 @@ select:
|
|
|
- if:
|
|
- if:
|
|
|
condition:
|
|
condition:
|
|
|
- lambda: |-
|
|
- lambda: |-
|
|
|
- return(id(mode).state) == "Daybreak";
|
|
|
|
|
|
|
+ return(id(light_mode).state) == "Daybreak";
|
|
|
then:
|
|
then:
|
|
|
- switch.turn_off: relay
|
|
- switch.turn_off: relay
|
|
|
- delay: 20s
|
|
- delay: 20s
|
|
@@ -174,7 +166,7 @@ select:
|
|
|
- if:
|
|
- if:
|
|
|
condition:
|
|
condition:
|
|
|
- lambda: |-
|
|
- lambda: |-
|
|
|
- return(id(mode).state) == "Night";
|
|
|
|
|
|
|
+ return(id(light_mode).state) == "Night";
|
|
|
then:
|
|
then:
|
|
|
- switch.turn_off: relay
|
|
- switch.turn_off: relay
|
|
|
- delay: 20s
|
|
- delay: 20s
|
|
@@ -186,16 +178,32 @@ select:
|
|
|
- switch.turn_off: relay
|
|
- switch.turn_off: relay
|
|
|
- delay: 200ms
|
|
- delay: 200ms
|
|
|
- switch.turn_on: relay
|
|
- switch.turn_on: relay
|
|
|
|
|
+ - lambda: |-
|
|
|
|
|
+ id(current_light) == id(light_mode).active_index();
|
|
|
|
|
|
|
|
-light:
|
|
|
|
|
- - platform: template
|
|
|
|
|
- name: None
|
|
|
|
|
- restore_mode: RESTORE_AND_OFF
|
|
|
|
|
- effects:
|
|
|
|
|
- - lambda:
|
|
|
|
|
- name: Day
|
|
|
|
|
- - lambda:
|
|
|
|
|
- name: Daybreak
|
|
|
|
|
- - lambda:
|
|
|
|
|
- name: Night
|
|
|
|
|
-
|
|
|
|
|
|
|
+switch:
|
|
|
|
|
+ - platform: gpio
|
|
|
|
|
+ pin: P8
|
|
|
|
|
+ id: relay
|
|
|
|
|
+ internal: true
|
|
|
|
|
+ restore_mode: ALWAYS_OFF
|
|
|
|
|
+ # Turn off red LED to show blue when turned on
|
|
|
|
|
+ on_turn_on:
|
|
|
|
|
+ - light.turn_on: red_led
|
|
|
|
|
+ # - switch.turn_off: led_1
|
|
|
|
|
+ # Turns on the red LED once the plug is turned off
|
|
|
|
|
+ on_turn_off:
|
|
|
|
|
+ - light.turn_off: red_led
|
|
|
|
|
+ # - switch.turn_on: led_1
|
|
|
|
|
+# - platform: template
|
|
|
|
|
+# name: mode
|
|
|
|
|
+# output: relay
|
|
|
|
|
+# internal: True
|
|
|
|
|
+# effects:
|
|
|
|
|
+# - lambda:
|
|
|
|
|
+# name: Day
|
|
|
|
|
+# - lambda:
|
|
|
|
|
+# name: Daybreak
|
|
|
|
|
+# - lambda:
|
|
|
|
|
+# name: Night
|
|
|
|
|
+
|