Ver Fonte

bath proxy only for Scale

Patryk M. Gutowski há 2 anos atrás
pai
commit
b928466794
1 ficheiros alterados com 92 adições e 5 exclusões
  1. 92 5
      ff-bath-bt-proxy-02.yaml

+ 92 - 5
ff-bath-bt-proxy-02.yaml

@@ -3,6 +3,26 @@ substitutions:
   low_devicename: ff_bath_bt_proxy_02
   friendly_devicename: FF Bath Bluetooth Proxy
 
+globals:
+  - id: asia_low
+    type: float
+    initial_value: '60.0'
+  - id: asia_high
+    type: float
+    initial_value: '94.95'
+  - id: patryk_low
+    type: float
+    initial_value: '95.0'
+  - id: patryk_high
+    type: float
+    initial_value: '110.0'
+  - id: ala_low
+    type: float
+    initial_value: '10.0'
+  - id: ala_high
+    type: float
+    initial_value: '20.0'
+
 packages:
   diag: !include common/diag.yaml
 
@@ -44,12 +64,79 @@ wifi:
   password: !secret iot_password
   domain: .int.mmax.cloud
   
-#esp32_ble_tracker:
-#  scan_parameters:
+esp32_ble_tracker:
+  scan_parameters:
     # We currently use the defaults to ensure Bluetooth
     # can co-exist with WiFi In the future we may be able to
     # enable the built-in coexistence logic in ESP-IDF
-#    active: true
+    active: true
+
+# bluetooth_proxy:
+#   active: true
+
+sensor:
+  - platform: xiaomi_miscale
+    mac_address: 'd0:3e:7d:3e:e3:5e'
+    weight:
+      name: "Xiaomi Mi Scale Weight"
+      id: weight_miscale
+      on_value:
+        then:
+          - lambda: |-
+              if (id(weight_miscale).state >= id(asia_low) && id(weight_miscale).state <= id(asia_high)) {
+                return id(weight_user_asia).publish_state(x);}
+              else if (id(weight_miscale).state >= id(patryk_low) && id(weight_miscale).state <= id(patryk_high)) {
+                return id(weight_user_patryk).publish_state(x);}
+              else if (id(weight_miscale).state >= id(ala_low) && id(weight_miscale).state <= id(ala_high)) {
+                return id(weight_user_ala).publish_state(x);}
+
+    impedance:
+      name: "Xiaomi Mi Scale Impedance"
+      id: impedance_miscale
+      on_value:
+        then:
+          - lambda: |-
+              if (id(weight_miscale).state >= id(asia_low) && id(weight_miscale).state <= id(asia_high)) {
+                return id(impedance_user_asia).publish_state(x);}
+              else if (id(weight_miscale).state >= id(patryk_low) && id(weight_miscale).state <= id(patryk_high)) {
+                return id(impedance_user_patryk).publish_state(x);}
+              else if (id(weight_miscale).state >= id(ala_low) && id(weight_miscale).state <= id(ala_high)) {
+                return id(impedance_user_ala).publish_state(x);}
+    clear_impedance: True
 
-bluetooth_proxy:
-  active: true
+  - platform: template
+    name: Weight Asia
+    id: weight_user_asia
+    unit_of_measurement: 'kg'
+    icon: mdi:weight-kilogram
+    accuracy_decimals: 2
+  - platform: template
+    name: Impedance Asia
+    id: impedance_user_asia
+    unit_of_measurement: 'Ω'
+    icon: mdi:omega
+    accuracy_decimals: 0
+  - platform: template
+    name: Weight Patryk
+    id: weight_user_patryk
+    unit_of_measurement: 'kg'
+    icon: mdi:weight-kilogram
+    accuracy_decimals: 2
+  - platform: template
+    name: Impedance Patryk
+    id: impedance_user_patryk
+    unit_of_measurement: 'Ω'
+    icon: mdi:omega
+    accuracy_decimals: 0
+  - platform: template
+    name: Weight Ala
+    id: weight_user_ala
+    unit_of_measurement: 'kg'
+    icon: mdi:weight-kilogram
+    accuracy_decimals: 2
+  - platform: template
+    name: Impedance Ala
+    id: impedance_user_ala
+    unit_of_measurement: 'Ω'
+    icon: mdi:omega
+    accuracy_decimals: 0