Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
projects:internetofthings:esphome [2021/02/19 18:25] – [BLE bluetooth tracker] scipio | projects:internetofthings:esphome [2021/07/06 07:26] (current) – [ESP32 cam] scipio | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== ESPHOME ====== | ====== ESPHOME ====== | ||
+ | |||
+ | ===== ESP32 cam ===== | ||
+ | |||
+ | * [[https:// | ||
+ | |||
+ | |||
+ | |||
+ | <code bash> | ||
+ | #!/bin/sh | ||
+ | |||
+ | TOKEN=... | ||
+ | |||
+ | PAYLOAD=" | ||
+ | |||
+ | |||
+ | curl -q -X POST \ | ||
+ | -d " | ||
+ | -H " | ||
+ | -H " | ||
+ | http:// | ||
+ | </ | ||
+ | |||
+ | in esp32 cam this section is missing in " | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | </ | ||
+ | |||
+ | esp32 entry (missing some values) | ||
+ | |||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | valid stream camera working in alexa | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | } | ||
+ | ] | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | ===== BLE tracker smartband ===== | ||
+ | |||
+ | ==== esphome ==== | ||
+ | |||
+ | enable esp32_ble_tracker and a binary sensor on ble_presence | ||
+ | < | ||
+ | esp32_ble_tracker: | ||
+ | |||
+ | binary_sensor: | ||
+ | - platform: ble_presence | ||
+ | mac_address: | ||
+ | id: miband_presence_scipio | ||
+ | name: " | ||
+ | </ | ||
+ | |||
+ | ==== hass ==== | ||
+ | |||
+ | automation directly on sensor created by esphome | ||
+ | < | ||
+ | - alias: cancello | ||
+ | trigger: | ||
+ | - entity_id: binary_sensor.miband_presence_scipio | ||
+ | platform: state | ||
+ | to: ' | ||
+ | for: | ||
+ | seconds: 2 | ||
+ | - entity_id: binary_sensor.miband_presence_scipio | ||
+ | platform: state | ||
+ | to: ' | ||
+ | for: | ||
+ | seconds: 2 | ||
+ | action: | ||
+ | - service: notify.alexa_media | ||
+ | data_template: | ||
+ | message: > | ||
+ | {% if is_state(' | ||
+ | ' | ||
+ | {% else %} | ||
+ | ' | ||
+ | {% endif %} | ||
+ | data: | ||
+ | type: announce | ||
+ | method: all | ||
+ | target: | ||
+ | - show | ||
+ | - Echo | ||
+ | </ | ||
+ | |||
+ | |||
+ | example of added binary sensor defined on ble sensor | ||
+ | < | ||
+ | binary_sensor: | ||
+ | - platform: template | ||
+ | sensors: | ||
+ | miband_scipio_sticky: | ||
+ | value_template: | ||
+ | {{is_state(' | ||
+ | delay_off: 60 | ||
+ | </ | ||
+ | |||
===== BLE bluetooth tracker (version 1) ===== | ===== BLE bluetooth tracker (version 1) ===== | ||
- | hass | + | hass input_boolean: |
+ | <code yaml> | ||
+ | beacon2_learn: | ||
+ | name: learn beacon2 | ||
+ | initial: off | ||
+ | icon: mdi: | ||
+ | |||
+ | beacon2_active: | ||
+ | name: beacon2 is recently seen | ||
+ | icon: mdi: | ||
+ | |||
+ | beacon2_trigger: | ||
+ | name: beacon2 is now detected | ||
+ | initial: off | ||
+ | icon: mdi: | ||
+ | </ | ||
+ | |||
+ | hass input_text: | ||
+ | < | ||
+ | beacon1: | ||
+ | name: BLE beacon1 | ||
+ | |||
+ | beacon2: | ||
+ | name: BLE beacon2 | ||
+ | </ | ||
+ | |||
+ | hass scripts: | ||
+ | < | ||
+ | set_ibeacon: | ||
+ | sequence: | ||
+ | - condition: template | ||
+ | value_template: | ||
+ | - service: script.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: " | ||
+ | - 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: | ||
+ | - service: input_boolean.turn_on | ||
+ | entity_id: input_boolean.beacon2_trigger | ||
+ | - delay: 1 | ||
+ | - service: input_boolean.turn_off | ||
+ | entity_id: input_boolean.beacon2_trigger | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | hass automations: | ||
+ | < | ||
+ | - alias: " | ||
+ | trigger: | ||
+ | platform: state | ||
+ | entity_id: input_sensor.beacon2_trigger | ||
+ | to: " | ||
+ | condition: | ||
+ | condition: state | ||
+ | entity_id: input_boolean.beacon2_active | ||
+ | state: " | ||
+ | action: | ||
+ | - service: input_boolean.turn_on | ||
+ | entity_id: input_boolean.beacon2_active | ||
+ | - service: notify.alexa_media | ||
+ | data: | ||
+ | message: " | ||
+ | data: | ||
+ | type: announce | ||
+ | method: all | ||
+ | target: | ||
+ | - show | ||
+ | - Echo | ||
+ | |||
+ | - alias: " | ||
+ | trigger: | ||
+ | platform: state | ||
+ | entity_id: input_boolean.beacon2_trigger | ||
+ | to: " | ||
+ | for: 140 | ||
+ | action: | ||
+ | - service: input_boolean.turn_off | ||
+ | entity_id: input_boolean.beacon2_active | ||
+ | - service: notify.alexa_media | ||
+ | data: | ||
+ | message: " | ||
+ | data: | ||
+ | type: announce | ||
+ | method: all | ||
+ | target: | ||
+ | - show | ||
+ | - Echo | ||
+ | </ | ||
+ | |||
+ | panel | ||
<code yaml> | <code yaml> | ||
- | input_text: | + | type: entities |
- | - ibeacon: | + | entities: |
- | name: ibeacon | + | - entity: input_boolean.beacon2_learn |
- | initial: not received | + | - entity: input_text.beacon2 |
- | + | - entity: input_boolean.beacon2_trigger | |
- | scripts: | + | - entity: input_boolean.beacon2_active |
- | | + | title: Tracker cancello |
- | sequence: | + | |
- | | + | |
- | | + | |
- | | + | |
- | value: "{{ ibeacon }}" | + | |
</ | </ | ||