A collection of my ESPHome components.
To use this repository you should confugure it inside your yaml-configuration:
external_components:
- source: github:https://dvb6666/esphome-components
or download component into custom_components
folder (you can use another name) and add following lines to your yaml-configuration:
external_components:
- source: custom_components
You can take a look at samples of usage of those components in examples folder.
Copy of myhomeiot BLE Client that allows:
- To read set of characteristics from device at the same connection.
- To write characteristics (when option
value
presents). You can skip executing Write-command when data array is empty by setting optionskip_empty
totrue
. Examples:
- service_uuid: '0000fff0-0000-1000-8000-00805f9b34fb'
characteristic_uuid: '0000fff1-0000-1000-8000-00805f9b34fb'
value: [0xFD, 0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCB]
- service_uuid: '0000fff0-0000-1000-8000-00805f9b34fb'
characteristic_uuid: '0000fff1-0000-1000-8000-00805f9b34fb'
skip_empty: true
value: !lambda |-
return {0xFD, 0x37, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCB};
- service_uuid: '0000fff0-0000-1000-8000-00805f9b34fb'
characteristic_uuid: '0000fff4-0000-1000-8000-00805f9b34fb'
notify: true
- To force update BLE-client with action
myhomeiot_ble_client2.force_update
or methodforce_update()
from lambda. Example:
button:
- platform: template
name: "Force Update"
on_press:
- myhomeiot_ble_client2.force_update:
id: my_ble_client
# - lambda: |-
# id(my_ble_client).force_update(); // same with lambda
myhomeiot_ble_client2:
- mac_address: "01:23:45:67:89:AB"
id: my_ble_client
- service_uuid: '180F'
characteristic_uuid: '2A19'
delay: 3s
# delay: !lambda |-
# return 3000; // same with lambda in microseconds
Difference from build-in ESPHome BLE Client:
- Always disconnects from device after reading characteristic, this will allow to save device battery. You can specify
update_interval
, defaults to 60min. - Uses lambda for parsing and extracting data into specific sensors make this component very flexible and useful for prototyping.
- There is no limit to the number of BLE Clients used (build-in BLE Client has limit of 3 instances). This component uses BLE Host component which you should count as one instance of build-in BLE Client. All BLE clients are processed sequentially inside the host component at time when they was detected and update interval reached.
Note: This example needs three template sensors with id: battery_level, tx_power, link_loss
esp32_ble_tracker:
myhomeiot_ble_host:
myhomeiot_ble_client2:
- mac_address: "01:23:45:67:89:AB"
update_interval: 300sec
services:
- service_uuid: '180F'
characteristic_uuid: '2A19'
- service_uuid: '1804'
characteristic_uuid: '2A07'
- service_uuid: '1803'
characteristic_uuid: '2A06'
on_value:
then:
lambda: |-
ESP_LOGD("M1", "Received [%d] for service %d", x[0], service);
if (service==1) id(battery_level).publish_state(x[0]);
else if (service==2) id(tx_power).publish_state(x[0]);
else if (service==3) id(link_loss).publish_state(x[0]);
external_components:
- source: github:https://myhomeiot/esphome-components
- source: github:https://dvb6666/esphome-components
Component-helper for control any quantity of MCLH-09 flower-sensors with BLE Client2. For every MCLH-09 device it will create sensors: battery level, temperature, soil, light, rssi.
esp32_ble_tracker:
myhomeiot_ble_host:
mclh_09_gateway:
interval: 10min
error_counting: true
raw_soil: false
mac_address:
- "00:00:00:11:11:11"
- "00:00:00:22:22:22"
- "00:00:00:33:33:33"
- "00:00:00:44:44:44"
external_components:
- source: github:https://myhomeiot/esphome-components
- source: github:https://dvb6666/esphome-components
Same as MCLH 09 Gateway, but for MQTT. Config example.
More configuration examples you can find in examples folder.