浏览代码

Working, clean config.

Thomas Chef 4 年之前
父节点
当前提交
c5163c1df6
共有 9 个文件被更改,包括 147 次插入0 次删除
  1. 1 0
      automations.yaml
  2. 41 0
      configuration.yaml
  3. 0 0
      groups.yaml
  4. 5 0
      input_booleans.yaml
  5. 29 0
      lights.yaml
  6. 52 0
      pyscript/ext_lights_control.py
  7. 0 0
      scenes.yaml
  8. 0 0
      scripts.yaml
  9. 19 0
      sensors.yaml

+ 1 - 0
automations.yaml

@@ -0,0 +1 @@
+[]

+ 41 - 0
configuration.yaml

@@ -0,0 +1,41 @@
+config:
+frontend:
+homeassistant:
+counter:
+logbook:
+notify:
+input_boolean:
+input_datetime:
+input_number:
+input_select:
+input_text:
+timer:
+recorder:
+  purge_keep_days: 5
+  db_url: mysql://hassio:hassiopassword@192.168.1.110/hass?charset=utf8
+logger:
+  logs:
+    rflink: debug
+    homeassistant.components.rflink: debug
+history:
+
+pyscript:
+  allow_all_imports: true
+
+rflink:
+  host: 127.0.0.1
+  port: 12345
+  wait_for_ack: false
+
+
+# Text to speech
+tts:
+  - platform: google_translate
+
+input_boolean: !include input_booleans.yaml
+sensor: !include sensors.yaml
+light: !include lights.yaml
+group: !include groups.yaml
+automation: !include automations.yaml
+script: !include scripts.yaml
+scene: !include scenes.yaml

+ 0 - 0
groups.yaml


+ 5 - 0
input_booleans.yaml

@@ -0,0 +1,5 @@
+
+
+exterior_lights_wanted_state:
+  name: Exterior lights, wanted state
+  icon: mdi:lightbulb

+ 29 - 0
lights.yaml

@@ -0,0 +1,29 @@
+
+
+- platform: rflink
+  automatic_add: true
+  devices:
+
+    newkaku_013242b6_2:
+      name: Exterior lights
+      type: switchable
+    newkaku_013242b5_2:
+      name: Exterior lights REPEATER
+      type: switchable
+    
+    newkaku_006d7076_1:
+      name: Main Button 1
+      aliases:
+        - newkaku_006d7076_0
+    newkaku_006d7076_2:
+      name: Main Button 2
+      aliases:
+        - newkaku_006d7076_0
+    newkaku_006d7076_3:
+      name: Main Button 3
+      aliases:
+        - newkaku_006d7076_0
+    newkaku_006d7076_4:
+      name: Main Button 4
+      aliases:
+        - newkaku_006d7076_0

+ 52 - 0
pyscript/ext_lights_control.py

@@ -0,0 +1,52 @@
+
+state.persist('pyscript.ext_light_has_been_day','false')
+state.persist('pyscript.ext_light_has_been_night','false')
+
+# Set that it has been midnight, and that it's ok to turn the light on
+@time_trigger("once(00:30:00)")
+def ext_light_has_been_night():
+	pyscript.ext_light_has_been_night = 'true'
+
+# Set that it has been noon, and that it's ok to turn off the light
+@time_trigger("once(12:30:00)")
+def ext_light_has_been_day():
+	pyscript.ext_light_has_been_day = 'true'
+
+
+@state_trigger("pyscript.ext_light_has_been_day == 'true' and int(sensor.lux_outside_the_garage) < 100")
+def automate_exterior_lights_on_in_evening():
+	pyscript.ext_light_has_been_day = 'false'
+	input_boolean.exterior_lights_wanted_state = 'on'
+
+@state_trigger("pyscript.ext_light_has_been_night == 'true' and int(sensor.lux_outside_the_garage) > 50")
+def automate_exterior_lights_off_in_morning():
+	pyscript.ext_light_has_been_night = 'false'
+	input_boolean.exterior_lights_wanted_state = 'off'
+
+
+
+@state_trigger("input_boolean.exterior_lights_wanted_state")
+@task_unique("control_ext_light", kill_me=True)
+def control_ext_light():
+
+    # Set max number of iterations
+    maxIterations = 5
+
+    # Loop until we have succeeded to controlling the light
+    while(
+             ( (sensor.exterior_light_status != input_boolean.exterior_lights_wanted_state) or 
+               (        light.exterior_lights!= input_boolean.exterior_lights_wanted_state) ) and maxIterations > 0
+    ):
+
+        # Find out if we should turn the light on or off
+        action = "turn_off" if input_boolean.exterior_lights_wanted_state == 'off' else "turn_on"
+        
+        service.call("light", action, entity_id="light.exterior_lights")
+        service.call("light", action, entity_id="light.exterior_lights_repeater")
+
+        log.info("Sleeping 60s.....")
+        trig_info = task.wait_until(state_trigger=["input_boolean.exterior_lights_wanted_state","sensor.exterior_light_status"], timeout=60)
+
+        maxIterations -= 1
+    
+    log.info(f"Exit control_ext_light")

+ 0 - 0
scenes.yaml


+ 0 - 0
scripts.yaml


+ 19 - 0
sensors.yaml

@@ -0,0 +1,19 @@
+
+
+- platform: sql
+  db_url: mysql://hassio:hassiopassword@192.168.1.110/RemoteRxLog
+  queries:
+    - name: Lux outside the garage
+      query: "SELECT CAST(AVG(data) AS signed) as data FROM (SELECT data FROM RemoteRxLog.rawTemp WHERE type = 'lux' and data < '65535' ORDER BY id DESC LIMIT 3) items;"
+      column: 'data'
+      unit_of_measurement: Lux
+    - name: Outside temperature
+      query: "SELECT temp1 FROM RemoteRxLog.temp order by ts desc LIMIT 1;"
+      column: 'temp1'
+      unit_of_measurement: C
+    - name: Piano-lamp repeater status
+      query: "SELECT IF(onOff>0,'on','off') AS status FROM RemoteRxLog.nexaLog where rxTx='R' and remote_id = '20071094' and button='2' order by ts desc LIMIT 1;"
+      column: 'status'
+    - name: Exterior light status
+      query: "SELECT IF(onOff>0,'on','off') AS status FROM RemoteRxLog.nexaLog where rxTx='R' and remote_id = '20071094' and button='1' order by ts desc LIMIT 1;"
+      column: 'status'