projects:internetofthings:esphome

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:internetofthings:esphome [2021/02/22 10:59] – [BLE bluetooth tracker (version 1)] scipioprojects:internetofthings:esphome [2021/07/06 07:26] (current) – [ESP32 cam] scipio
Line 1: Line 1:
 ====== ESPHOME ====== ====== ESPHOME ======
  
-===== BLE bluetooth tracker (version 1) =====+===== ESP32 cam =====
  
-hass +  * [[https://github.com/esphome/esphome/pull/1905|rtsp into esp32cam progress]]
-<code yaml> +
-input_boolean: +
-  allarme: +
-    name: allarme armato +
-    initial: off +
-    icon: mdi:alarm-plus+
  
-  beacon1: 
-    name: learn beacon1 
-    initial: off 
-    icon: mdi:mdi-tag-plus 
  
-  beacon2: 
-    name: learn beacon2 
-    initial: off 
-    icon: mdi:mdi-tag-plus 
  
-  beacon1_active: +<code bash> 
-    name: beacon1 is detected +#!/bin/sh
-    icon: mdi:mdi-account-check+
  
-  beacon2_active: +TOKEN=...
-    name: beacon2 is detected +
-    icon: mdi:mdi-account-check+
  
-input_text: +PAYLOAD="{\"directive\"{\"header\"{\"namespace\": \"Alexa.Discovery\", \"name\"\"Discover\", \"payloadVersion\"\"3\", \"messageId\": \"8db404f7-f5a1-495e-9a30-3a8af3bf94e0\"}, \"payload\": {\"scope\": {\"type\": \"BearerToken\", \"token\"\"...\"}}}}"
-  beacon1: +
-    name: BLE beacon1 +
-  beacon2: +
-    nameBLE beacon2 +
-    +
  
-scripts: 
-  set_ibeacon: 
-    sequence: 
-      - condition: template 
-        value_template: "{{ ibeacon != '' }}" 
-      - service: script.set_beacon1 
-        data_template: 
-          ibeacon: "{{ ibeacon }}" 
-      - service: script.set_beacon2 
-        data_template: 
-          ibeacon: "{{ ibeacon }}" 
  
-  set_beacon1: +curl -q -X POST \ 
-    sequence: +  -"$PAYLOAD\ 
-      service: script.beacon1_active +  -H "AuthorizationBearer $TOKEN\ 
-        data_template: +  -H "Content-Typeapplication/json" \ 
-          ibeacon: "{{ ibeacon }}+  http://localhost:8123/api/alexa/smart_home | jq '.event.payload.endpoints[] | select(.displayCategories[0]=="CAMERA")' 
-      condition: state +</code>
-        entity_id: input_boolean.beacon1 +
-        state: "on" +
-      serviceinput_text.set_value +
-        data_template: +
-          entity_idinput_text.beacon1 +
-          value: "{{ ibeacon }}+
-      - service: input_boolean.turn_off +
-        entity_id: input_boolean.beacon1+
  
-  set_beacon2: +in esp32 cam this section is missing in "capabilities" 
-    sequence+<code javascript> 
-      - servicescript.beacon2_active +
-        data_template: +      "type""AlexaInterface", 
-          ibeacon: "{{ ibeacon }}+      "interface""Alexa.CameraStreamController", 
-      - conditionstate +      "version": "3", 
-        entity_id: input_boolean.beacon2 +      "cameraStreamConfigurations"[ 
-        state: "on+        { 
-      - serviceinput_text.set_value +          "protocols"
-        data_template+            "HLS
-          entity_idinput_text.beacon2 +          ], 
-          value: "{{ ibeacon }}+          "resolutions"[ 
-      - serviceinput_boolean.turn_off +            { 
-        entity_id: input_boolean.beacon2+              "width"1280, 
 +              "height": 720 
 +            } 
 +          ], 
 +          "authorizationTypes"
 +            "NONE" 
 +          ], 
 +          "videoCodecs"
 +            "H264
 +          ], 
 +          "audioCodecs"
 +            "AAC" 
 +          ] 
 +        
 +      ] 
 +    }, 
 +</code>
  
-  beacon1_active: +esp32 entry (missing some values)
-    sequence: +
-      - condition: template +
-        value_template: "{{ ibeacon == states('input_text.beacon1'}}" +
-      - service: input_boolean.turn_on +
-        entity_id: input_boolean.beacon1_active +
-      - delay: 30 +
-      - service: input_boolean.turn_off +
-        entity_id: input_boolean.beacon1_active+
  
-  beacon2_active+<code javascript> 
-    sequence+
-      - conditiontemplate +  "displayCategories"[ 
-        value_template: "{{ ibeacon == states('input_text.beacon2') }}" +    "CAMERA" 
-      - serviceinput_boolean.turn_on +  ], 
-        entity_idinput_boolean.beacon2_active +  "cookie"{}, 
-      - delay30 +  "endpointId""camera#citofono", 
-      - serviceinput_boolean.turn_off +  "friendlyName": "citofono", 
-        entity_idinput_boolean.beacon2_active+  "description": "camera.citofono via Home Assistant", 
 +  "manufacturerName": "Home Assistant", 
 +  "additionalAttributes": { 
 +    "manufacturer": "Home Assistant", 
 +    "model": "camera", 
 +    "softwareVersion": "2021.6.6", 
 +    "customIdentifier": "-camera.citofono" 
 +  }
 +  "capabilities":
 +    { 
 +      "type""AlexaInterface", 
 +      "interface""Alexa.EndpointHealth", 
 +      "version""3", 
 +      "properties"{ 
 +        "supported"
 +          { 
 +            "name": "connectivity" 
 +          } 
 +        ], 
 +        "proactivelyReported": true, 
 +        "retrievable": true 
 +      } 
 +    }, 
 +    { 
 +      "type": "AlexaInterface", 
 +      "interface": "Alexa", 
 +      "version": "3" 
 +    } 
 +  ] 
 +
 +</code>
  
-           
-           
-automations: 
-  - alias: "beacon2 is active" 
-    trigger: 
-      platform: state 
-      entity_id: input_boolean.beacon2_active 
-      to: "on" 
-    action: 
-      - service: notify.alexa_media 
-        data: 
-          message: "Stefano è arrivato" 
-          data: 
-            type: announce 
-            method: all 
-          target: 
-            - show 
-            - Echo 
  
-  alias: "beacon2 is not active after last presence+valid stream camera working in alexa 
-    trigger:+<code javascript> 
 +
 +  "displayCategories":
 +    "CAMERA" 
 +  ], 
 +  "cookie": {}, 
 +  "endpointId": "camera#cancello", 
 +  "friendlyName": "camera cancello", 
 +  "description": "camera.cancello via Home Assistant", 
 +  "manufacturerName": "Home Assistant", 
 +  "additionalAttributes":
 +    "manufacturer": "Home Assistant", 
 +    "model": "camera", 
 +    "softwareVersion": "2021.6.6", 
 +    "customIdentifier": "-camera.cancello" 
 +  }, 
 +  "capabilities"
 +    { 
 +      "type": "AlexaInterface", 
 +      "interface": "Alexa.CameraStreamController", 
 +      "version": "3", 
 +      "cameraStreamConfigurations":
 +        { 
 +          "protocols":
 +            "HLS" 
 +          ], 
 +          "resolutions":
 +            { 
 +              "width": 1280, 
 +              "height": 720 
 +            } 
 +          ], 
 +          "authorizationTypes":
 +            "NONE" 
 +          ], 
 +          "videoCodecs":
 +            "H264" 
 +          ], 
 +          "audioCodecs":
 +            "AAC" 
 +          ] 
 +        } 
 +      ] 
 +    }, 
 +    { 
 +      "type": "AlexaInterface", 
 +      "interface": "Alexa.EndpointHealth", 
 +      "version": "3", 
 +      "properties":
 +        "supported":
 +          { 
 +            "name": "connectivity" 
 +          } 
 +        ], 
 +        "proactivelyReported": true, 
 +        "retrievable": true 
 +      } 
 +    }, 
 +    { 
 +      "type": "AlexaInterface", 
 +      "interface": "Alexa", 
 +      "version": "3" 
 +    } 
 +  ] 
 +
 + 
 +</code> 
 +===== BLE tracker smartband ===== 
 + 
 +==== esphome ==== 
 + 
 +enable esp32_ble_tracker and a binary sensor on ble_presence 
 +<code> 
 +esp32_ble_tracker: 
 + 
 +binary_sensor: 
 +  - platform: ble_presence 
 +    mac_address: E8:36:FD:20:E3:54 
 +    id: miband_presence_scipio 
 +    name: "MiBand presence scipio" 
 +</code> 
 + 
 +==== hass ==== 
 + 
 +automation directly on sensor created by esphome 
 +<code> 
 +- alias: cancello 
 +  trigger: 
 +    - entity_id: binary_sensor.miband_presence_scipio
       platform: state       platform: state
-      entity_id: input_boolean.beacon2_active +      to: 'on'
-      to: "off"+
       for:       for:
-        minutes1 +        seconds2 
-    action: +    - entity_idbinary_sensor.miband_presence_scipio
-      servicenotify.alexa_media +
-        data: +
-          message: "Stefano è partito" +
-          data: +
-            type: announce +
-            method: all +
-          target: +
-            - show +
-            - Echo +
- +
-  - alias: "beacon1 is active" +
-    trigger:+
       platform: state       platform: state
-      entity_idinput_boolean.beacon1_active +      to'off' 
-      to"on" +      for
-    action: +        seconds:
-      - service: light.turn_on+  action: 
 +    - service: notify.alexa_media 
 +      data_template: 
 +        message: > 
 +          {% if is_state('binary_sensor.miband_presence_scipio', 'on') %} 
 +            'Stefano è arrivato' 
 +          {% else %} 
 +            'Stefano è partito' 
 +          {% endif %} 
 +        data: 
 +          type: announce 
 +          method: all
         target:         target:
-          entity_id: light.ikea_of_sweden_tradfri_bulb_e27_ws_opal_980lm_c969e5fe_level_light_color_on_off+          - show 
 +          - Echo 
 +</code>
  
  
-  alias"beacon1 is not active after last presence+example of added binary sensor defined on ble sensor 
-    trigger+<code> 
-      platform: state +binary_sensor: 
-      entity_id: input_boolean.beacon1_active +  platformtemplate 
-      to: "off+    sensors: 
-      for+      miband_scipio_sticky: 
-        minutes: 1 +        value_template: >- 
-    action: +          {{is_state('binary_sensor.miband_presence_scipio', 'on')}} 
-      - service: light.turn_off+        delay_off: 60 
 +</code> 
 + 
 + 
 +===== BLE bluetooth tracker (version 1) ===== 
 + 
 +hass input_boolean: 
 +<code yaml> 
 +beacon2_learn: 
 +  name: learn beacon2 
 +  initial: off 
 +  icon: mdi:mdi-tag-plus 
 + 
 +beacon2_active: 
 +  name: beacon2 is recently seen 
 +  icon: mdi:mdi-account-check 
 + 
 +beacon2_trigger: 
 +  name: beacon2 is now detected 
 +  initial: off 
 +  icon: mdi:mdi-account-check 
 +</code> 
 + 
 +hass input_text: 
 +<code> 
 +beacon1: 
 +  name: BLE beacon1 
 + 
 +beacon2: 
 +  name: BLE beacon2 
 +</code> 
 + 
 +hass scripts: 
 +<code> 
 +set_ibeacon: 
 +  sequence: 
 +    - condition: template 
 +      value_template: "{{ ibeacon != '' }}
 +    - servicescript.set_beacon1 
 +      data_template: 
 +        ibeacon: "{{ ibeacon }}" 
 +    - service: script.set_beacon2 
 +      data_template: 
 +        ibeacon: "{{ ibeacon }}" 
 + 
 +set_beacon2: 
 +  sequence: 
 +    - service: script.beacon2_active 
 +      data_template: 
 +        ibeacon: "{{ ibeacon }}" 
 +    - condition: state 
 +      entity_id: input_boolean.beacon2_learn 
 +      state: "on" 
 +    - service: input_text.set_value 
 +      data_template
 +        entity_id: input_text.beacon2 
 +        value: "{{ ibeacon }}" 
 +    - service: input_boolean.turn_off 
 +      entity_id: input_boolean.beacon2_learn 
 + 
 +beacon2_active: 
 +  sequence: 
 +    - condition: template 
 +      value_template: "{{ ibeacon == states('input_text.beacon2') }}" 
 +    - service: input_boolean.turn_on 
 +      entity_id: input_boolean.beacon2_trigger 
 +    - delay: 1 
 +    - service: input_boolean.turn_off 
 +      entity_id: input_boolean.beacon2_trigger 
 + 
 + 
 +</code> 
 + 
 + 
 +           
 +hass automations: 
 +<code> 
 +- alias: "beacon2 is active" 
 +  trigger: 
 +    platform: state 
 +    entity_id: input_sensor.beacon2_trigger 
 +    to: "on" 
 +  condition: 
 +    condition: state 
 +    entity_id: input_boolean.beacon2_active 
 +    state: "off" 
 +  action: 
 +    - service: input_boolean.turn_on 
 +      entity_id: input_boolean.beacon2_active 
 +    - service: notify.alexa_media 
 +      data: 
 +        message: "Stefano è arrivato" 
 +        data: 
 +          type: announce 
 +          method: all
         target:         target:
-          entity_id: light.ikea_of_sweden_tradfri_bulb_e27_ws_opal_980lm_c969e5fe_level_light_color_on_off+          - show 
 +          - Echo
  
 +- alias: "beacon2 is not active after last presence"
 +  trigger:
 +    platform: state
 +    entity_id: input_boolean.beacon2_trigger
 +    to: "off"
 +    for: 140
 +  action:
 +    - service: input_boolean.turn_off
 +      entity_id: input_boolean.beacon2_active
 +    - service: notify.alexa_media
 +      data:
 +        message: "Stefano è partito"
 +        data:
 +          type: announce
 +          method: all
 +        target:
 +          - show
 +          - Echo
 </code> </code>
  
Line 164: Line 344:
 type: entities type: entities
 entities: entities:
-  - entity: input_boolean.beacon1 +  - entity: input_boolean.beacon2_learn 
-  - entity: input_text.beacon1 +  - entity: input_text.beacon2 
-  - entity: sensor.wifi_signal_sensor +  - entity: input_boolean.beacon2_trigger 
-  - entity: input_boolean.beacon1_active +  - entity: input_boolean.beacon2_active 
-  - entity: >- +title: Tracker cancello
-      light.ikea_of_sweden_tradfri_bulb_e27_ws_opal_980lm_c969e5fe_level_light_color_on_off +
-title: Tracker soggiorno+
 </code> </code>
  
  • projects/internetofthings/esphome.1613987993.txt.gz
  • Last modified: 2021/02/22 10:59
  • by scipio