Parcourir la source

Update to 2023_3 version. Added MQTT Lights

pi il y a 2 ans
Parent
commit
07503a0fc8
6 fichiers modifiés avec 94 ajouts et 53 suppressions
  1. 22 7
      configuration.yaml
  2. 54 0
      mqtt.yaml
  3. 3 0
      pyscript/airpurifyer.py
  4. 11 0
      pyscript/state_goto.py
  5. 4 4
      pyscript/wall_buttons.py
  6. 0 42
      sensors.yaml

+ 22 - 7
configuration.yaml

@@ -24,6 +24,8 @@ logger:
 #    rflink: debug
 #    homeassistant.components.rflink: debug
 
+mobile_app:
+
 history:
 system_health:
 
@@ -32,12 +34,6 @@ http:
   trusted_proxies:
     - 192.168.1.110
 
-mqtt:
-  broker: 192.168.1.110
-  port: 1883
-  username: pi
-  password: !secret MQTT_PASSWORD
-
 pyscript:
   allow_all_imports: true
 
@@ -74,9 +70,28 @@ tts:
 switch: !include switches.yaml
 input_boolean: !include input_booleans.yaml
 input_number: !include input_numbers.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
+mqtt: !include mqtt.yaml
+
+
+
+sql:
+  - name: "Exterior light status"
+    db_url: mysql://hassio:hassiopassword@192.168.1.110/RemoteRxLog
+    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'
+  - name: "Outside temperature"
+    db_url: mysql://hassio:hassiopassword@192.168.1.110/RemoteRxLog
+    query: "SELECT temp1 FROM RemoteRxLog.temp order by ts desc LIMIT 1;"
+    column: 'status'
+    unit_of_measurement: "°C"
+  - name: "Piano-lamp repeater status"
+    db_url: mysql://hassio:hassiopassword@192.168.1.110/RemoteRxLog
+    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'
+  
+  

+ 54 - 0
mqtt.yaml

@@ -0,0 +1,54 @@
+sensor:
+  - name: "Temperatur Hällby"
+    state_topic: "micke/outside/temperature"
+    unit_of_measurement: "°C"
+  - name: Lux Hällby
+    state_topic: "micke/lux/lux_calibrated"
+    unit_of_measurement: "Lux"
+  - name: Lux outside the garage
+    state_topic: "sensors/outside/lux"
+    unit_of_measurement: "Lux"
+  - name: SMHI Temperature
+    state_topic: "sensors/outside/smhiTemperature"
+    unit_of_measurement: "°C"
+  - name: Frank Temperature
+    state_topic: "sensors/outside/frankTemperature"
+    unit_of_measurement: "°C"
+
+binary_sensor:
+  - name: "Kitchen worklight switch"
+    unique_id: "kitchen_worklight_switch"
+    state_topic: "kitchen/worklight_switch"
+    availability:
+      - topic: "kitchen/worklight_switch/available"
+    qos: 0
+    device_class: power
+
+light:
+  - schema: json
+    name: "Kitchen worktop lights"
+    unique_id: "kitchen_worktop_lights"
+    state_topic: "kitchen/worktop/lights"
+    command_topic: "kitchen/worktop/lights/set"
+    availability:
+      - topic: "kitchen/worktop/lights/available"
+    retain: true
+    optimistic: false
+    qos: 0
+    brightness_scale: 1000
+    max_mireds: 370
+    min_mireds: 250
+    brightness: true
+    color_mode: true
+    supported_color_modes: ["color_temp"]
+
+  - schema: json
+    name: "Kitchen test"
+    unique_id: "kitchen_test"
+    state_topic: "kitchen/worktop/lights_test"
+    command_topic: "kitchen/worktop/lights_test/set"
+    retain: false
+    optimistic: false
+    qos: 0
+    brightness_scale: 1000
+    brightness: true

+ 3 - 0
pyscript/airpurifyer.py

@@ -1,4 +1,6 @@
 import asyncio
+
+""" Not used right now
 from aioairctrl import CoAPClient
 
 # can set aqil (0,100) or uil (0,1) to control the brightness of the display
@@ -37,3 +39,4 @@ def turn_on_airpurifyer_trigger_func():
     log.info("React to door OPEN")
     input_boolean.philips_airpurifyer = 'on'
 
+"""

+ 11 - 0
pyscript/state_goto.py

@@ -28,6 +28,8 @@ def state_goto_all_on():
     cs = getCurrentState()
     log.info(f"********* ALL ON *********** State: " + str(cs) )
     light.turn_on(entity_id='light.tradfri_bulb')   # Stora flyglampan
+    light.turn_on(entity_id='light.hall_inner')
+    light.turn_on(entity_id='light.hall_door')
     #switch.turn_on(entity_id='switch.matsal')
     for x in range(2):
         switch.turn_on(entity_id='switch.group_button_all')
@@ -47,6 +49,9 @@ def state_goto_window():
     log.info(f"********* WINDOW *********** State: " + str(cs) )
     light.turn_off(entity_id='light.tradfri_bulb')
     switch.turn_off(entity_id='switch.matsal')
+    light.turn_off(entity_id='light.hall_inner')
+    light.turn_off(entity_id='light.hall_door')
+
     
     if cs == 4 or cs == 2:  # From Off or already Window
         for x in range(2):
@@ -79,6 +84,9 @@ def state_goto_morning():
     log.info(f"********* MORNING *********** State: " + str(cs) )
     light.turn_off(entity_id='light.tradfri_bulb')
     switch.turn_off(entity_id='switch.matsal')
+    light.turn_off(entity_id='light.hall_inner')
+    light.turn_on(entity_id='light.hall_door')
+
     if cs == 4 or cs == 3:  # Off or already Morning
         for x in range(2):
             light.turn_on(entity_id=' light.main_button_4')
@@ -113,6 +121,9 @@ def state_goto_all_off():
     cs = getCurrentState()
     log.info(f"********* ALL OFF *********** State: " + str(cs) )
     light.turn_off(entity_id='light.tradfri_bulb')
+    light.turn_off(entity_id='light.hall_inner')
+    light.turn_off(entity_id='light.hall_door')
+
     #switch.turn_off(entity_id='switch.matsal')  # Temp disable when high energy prices
     #switch.turn_off(entity_id='switch.tradfri_outlet')  # Sovrum OFF  # Temp disable when high energy prices
     for x in range(2):

+ 4 - 4
pyscript/wall_buttons.py

@@ -56,12 +56,12 @@ def hallway_wall_button(entity_id=None, state=None):
         pyscript.state_goto_all_on()
     
     if( entity_id == 'switch.mode_panel_2' ):   # Window
-        #pyscript.state_goto_window()
-        log.info(f"This mode has been disabled.")
+        pyscript.state_goto_window()
+        #log.info(f"This mode has been disabled.")
     
     if( entity_id == 'switch.mode_panel_3' ):   # Morning
-        log.info(f"This mode has been disabled.")
-        #pyscript.state_goto_morning()
+        #log.info(f"This mode has been disabled.")
+        pyscript.state_goto_morning()
     
     if( entity_id == 'switch.mode_panel_4' ):   # All OFF
         pyscript.state_goto_all_off()

+ 0 - 42
sensors.yaml

@@ -1,42 +0,0 @@
-
-
-- platform: sql
-  db_url: mysql://hassio:hassiopassword@192.168.1.110/RemoteRxLog
-  queries:
-    - 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'
-
-
-
-- platform: mqtt
-  name: Temperatur Hällby
-  state_topic: "micke/outside/temperature"
-  unit_of_measurement: "°C"
-
-- platform: mqtt
-  name: Lux Hällby
-  state_topic: "micke/lux/lux_calibrated"
-  unit_of_measurement: "Lux"
-
-- platform: mqtt
-  name: Lux outside the garage
-  state_topic: "sensors/outside/lux"
-  unit_of_measurement: "Lux"
-
-- platform: mqtt
-  name: SMHI Temperature
-  state_topic: "sensors/outside/smhiTemperature"
-  unit_of_measurement: C
-
-- platform: mqtt
-  name: Frank Temperature
-  state_topic: "sensors/outside/frankTemperature"
-  unit_of_measurement: C