Ver código fonte

Small adjustment.

Thomas Chef 4 anos atrás
pai
commit
bd65b1563e
1 arquivos alterados com 21 adições e 6 exclusões
  1. 21 6
      packages/test_stuff.yaml

+ 21 - 6
packages/test_stuff.yaml

@@ -27,22 +27,37 @@ input_boolean:
 automation:
   - alias: Piano-lamp control automation
     trigger:
-      platform: template
+    - platform: template
       value_template: >
         {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
           false
         {% else %}
           true
         {% endif %}
-    action:
-    - service: >
-        {% if states('input_boolean.piano_light_wanted_state') == "on" %}
-          light.turn_on
+    - platform: event
+      event_type: timer.finished
+      event_data:
+        entity_id: timer.piano_lamp_control_timer
+    condition: 
+      condition: template
+      value_template: >
+        {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
+          false
         {% else %}
-          light.turn_off
+          true
         {% endif %}
+    action:
+    - service_template: light.turn_{{states('input_boolean.piano_light_wanted_state')}}
       entity_id: light.piano_lamp_repeater
 
+    - service_template: >
+        {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
+          timer.cancel
+        {% else %}
+          timer.start
+        {% endif %}
+      entity_id: timer.piano_lamp_control_timer
+
 
 timer:
   piano_lamp_control_timer: