Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- mac_address_jukka_salon: 'C4:7C:8D:6C:5B:A0' # Jukka Salon
- mac_address_dracena_salon: 'C4:7C:8D:6C:85:1A' # Dracena Salon
- mac_address_zegarek_salon: 'E7:2E:01:71:B9:21' # Zegarek Salon (LYWSD02MMC)
- esphome:
- name: 'esp32-dol'
- platform: ESP32
- board: esp-wrover-kit
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Esp32 Dol Fallback Hotspot"
- password: !secret ap_wifi_password
- captive_portal:
- # Enable logging
- logger:
- # Enable Home Assistant API
- api:
- password: !secret api_password
- ota:
- password: !secret ota_password
- external_components:
- - source: github://myhomeiot/esphome-components
- # Enable Bluetooth scanning for this ESP32
- esp32_ble_tracker:
- # PASSIVE
- ble_gateway:
- devices:
- - mac_address: ${mac_address_jukka_salon} # Jukka Salon
- - mac_address: ${mac_address_dracena_salon} # Dracaena Salon
- - mac_address: ${mac_address_zegarek_salon} # Zegarek Salon
- on_ble_advertise:
- then:
- homeassistant.service:
- service: ble_monitor.parse_data
- data:
- packet: !lambda return packet;
- # ACTIVE
- # Flower Care (HHCCJCY01) nie raportuje stanu baterii, co 48h nawiązujemy aktywne połączenie w celu odczytania stanu
- # Odczytany stan wysyłamy do Passibe BLE Monitor'a
- myhomeiot_ble_host:
- myhomeiot_ble_client:
- - mac_address: ${mac_address_jukka_salon}
- service_uuid: '1204'
- characteristic_uuid: '1A02'
- update_interval: 48h
- on_value:
- then:
- homeassistant.service:
- service: ble_monitor.parse_data
- data:
- packet: !lambda |-
- if (x.size() < 2)
- {
- ESP_LOGE("myhomeiot_ble_client", "payload has wrong size (%d)", x.size());
- return "";
- };
- ESP_LOGI("myhomeiot_ble_client", "Battery (%d%%), firmware (%s)", x[0], std::string(x.begin(), x.end()).substr(2).c_str());
- char buffer[70 + 1];
- const uint8_t *remote_bda = xthis.remote_bda();
- snprintf(buffer, sizeof(buffer), "043E2002010000%02X%02X%02X%02X%02X%02X14020106030295FE0C1695FE41209800000A1001%02X00",
- remote_bda[5], remote_bda[4], remote_bda[3], remote_bda[2], remote_bda[1], remote_bda[0], x[0]);
- return std::string(buffer).c_str();
- - mac_address: ${mac_address_dracena_salon}
- service_uuid: '1204'
- characteristic_uuid: '1A02'
- update_interval: 48h
- on_value:
- then:
- homeassistant.service:
- service: ble_monitor.parse_data
- data:
- packet: !lambda |-
- if (x.size() < 2)
- {
- ESP_LOGE("myhomeiot_ble_client", "payload has wrong size (%d)", x.size());
- return "";
- };
- ESP_LOGI("myhomeiot_ble_client", "Battery (%d%%), firmware (%s)", x[0], std::string(x.begin(), x.end()).substr(2).c_str());
- char buffer[70 + 1];
- const uint8_t *remote_bda = xthis.remote_bda();
- snprintf(buffer, sizeof(buffer), "043E2002010000%02X%02X%02X%02X%02X%02X14020106030295FE0C1695FE41209800000A1001%02X00",
- remote_bda[5], remote_bda[4], remote_bda[3], remote_bda[2], remote_bda[1], remote_bda[0], x[0]);
- return std::string(buffer).c_str();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement