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/22 10:58] – [BLE bluetooth tracker (version 1)] scipio | projects: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:// |
| - | <code yaml> | + | |
| - | input_boolean: | + | |
| - | allarme: | + | |
| - | name: allarme armato | + | |
| - | initial: off | + | |
| - | icon: mdi: | + | |
| - | beacon1: | ||
| - | name: learn beacon1 | ||
| - | initial: off | ||
| - | icon: mdi: | ||
| - | beacon2: | ||
| - | name: learn beacon2 | ||
| - | initial: off | ||
| - | icon: mdi: | ||
| - | beacon1_active: | + | <code bash> |
| - | name: beacon1 is detected | + | #!/bin/sh |
| - | icon: mdi: | + | |
| - | beacon2_active: | + | TOKEN=... |
| - | name: beacon2 is detected | + | |
| - | icon: mdi: | + | |
| - | input_text: | + | PAYLOAD=" |
| - | beacon1: | + | |
| - | | + | |
| - | beacon2: | + | |
| - | name: BLE beacon2 | + | |
| - | | + | |
| - | 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_beacon1: | + | curl -q -X POST \ |
| - | sequence: | + | -d "$PAYLOAD" |
| - | - service: script.beacon1_active | + | -H " |
| - | data_template: | + | -H " |
| - | ibeacon: | + | http://localhost:8123/ |
| - | - condition: state | + | </ |
| - | entity_id: input_boolean.beacon1 | + | |
| - | state: "on" | + | |
| - | - service: input_text.set_value | + | |
| - | | + | |
| - | entity_id: input_text.beacon1 | + | |
| - | value: | + | |
| - | - service: input_boolean.turn_off | + | |
| - | entity_id: input_boolean.beacon1 | + | |
| - | set_beacon2: | + | in esp32 cam this section is missing in " |
| - | | + | <code javascript> |
| - | | + | { |
| - | | + | " |
| - | ibeacon: "{{ ibeacon }}" | + | |
| - | | + | " |
| - | | + | |
| - | state: "on" | + | |
| - | - service: input_text.set_value | + | " |
| - | | + | |
| - | | + | ], |
| - | | + | " |
| - | - service: input_boolean.turn_off | + | { |
| - | | + | " |
| + | " | ||
| + | } | ||
| + | | ||
| + | " | ||
| + | " | ||
| + | | ||
| + | " | ||
| + | | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | | ||
| + | ] | ||
| + | }, | ||
| + | </ | ||
| - | beacon1_active: | + | esp32 entry (missing some values) |
| - | sequence: | + | |
| - | - condition: template | + | |
| - | value_template: | + | |
| - | - 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> |
| - | | + | { |
| - | - condition: template | + | " |
| - | | + | |
| - | | + | ], |
| - | | + | " |
| - | | + | " |
| - | | + | " |
| - | | + | " |
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | " | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | " | ||
| + | } | ||
| + | ], | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | }, | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| - | | ||
| - | | ||
| - | automations: | ||
| - | - alias: " | ||
| - | trigger: | ||
| - | platform: state | ||
| - | entity_id: input_boolean.beacon2_active | ||
| - | to: " | ||
| - | action: | ||
| - | - service: notify.alexa_media | ||
| - | data: | ||
| - | message: " | ||
| - | data: | ||
| - | type: announce | ||
| - | method: all | ||
| - | target: | ||
| - | - show | ||
| - | - Echo | ||
| - | | + | valid stream camera working in alexa |
| - | trigger: | + | <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 | ||
| + | | ||
| + | - entity_id: binary_sensor.miband_presence_scipio | ||
| platform: state | platform: state | ||
| - | | + | to: ' |
| - | | + | |
| for: | for: | ||
| - | | + | |
| - | | + | - entity_id: binary_sensor.miband_presence_scipio |
| - | | + | |
| - | data: | + | |
| - | message: " | + | |
| - | data: | + | |
| - | type: announce | + | |
| - | method: all | + | |
| - | target: | + | |
| - | - show | + | |
| - | - Echo | + | |
| - | + | ||
| - | - alias: " | + | |
| - | trigger: | + | |
| platform: state | platform: state | ||
| - | | + | |
| - | | + | |
| - | action: | + | |
| - | - service: | + | |
| + | - service: | ||
| + | data_template: | ||
| + | message: > | ||
| + | {% if is_state(' | ||
| + | ' | ||
| + | {% else %} | ||
| + | ' | ||
| + | {% endif %} | ||
| + | data: | ||
| + | type: announce | ||
| + | method: all | ||
| target: | target: | ||
| - | | + | |
| + | - Echo | ||
| + | </ | ||
| - | | + | example of added binary sensor defined on ble sensor |
| - | | + | < |
| - | | + | binary_sensor: |
| - | entity_id: input_boolean.beacon1_active | + | |
| - | | + | sensors: |
| - | | + | miband_scipio_sticky: |
| - | | + | value_template: |
| - | action: | + | {{is_state(' |
| - | - service: | + | delay_off: 60 |
| + | </ | ||
| + | |||
| + | |||
| + | ===== BLE bluetooth tracker (version 1) ===== | ||
| + | |||
| + | hass input_boolean: | ||
| + | <code yaml> | ||
| + | beacon2_learn: | ||
| + | name: learn beacon2 | ||
| + | initial: off | ||
| + | icon: mdi: | ||
| + | |||
| + | beacon2_active: | ||
| + | name: beacon2 | ||
| + | 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: | ||
| + | | ||
| + | | ||
| + | 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 | ||
| + | | ||
| + | - service: input_text.set_value | ||
| + | | ||
| + | | ||
| + | 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 | ||
| + | | ||
| + | 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: " | ||
| + | | ||
| + | - service: input_boolean.turn_on | ||
| + | | ||
| + | | ||
| + | data: | ||
| + | message: " | ||
| + | data: | ||
| + | type: announce | ||
| + | method: all | ||
| target: | target: | ||
| - | | + | |
| + | - 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 | ||
| </ | </ | ||
| Line 164: | Line 344: | ||
| type: entities | type: entities | ||
| entities: | entities: | ||
| - | - entity: input_boolean.beacon2 | + | - entity: input_boolean.beacon2_learn |
| - entity: input_text.beacon2 | - entity: input_text.beacon2 | ||
| - | title: | + | - entity: input_boolean.beacon2_trigger |
| + | - entity: input_boolean.beacon2_active | ||
| + | title: | ||
| </ | </ | ||