ESPhome for Maytronics pool cover

Hi,

If you have a Maytronics pool cover with a bluetooth box v2.0, here’s a super simple way to integrate it with Home Assistant. You just need any ESP32, to prepare it for ESPhome and then use this YAML:

esp32_ble_tracker:

ble_client:
  - mac_address: YOUR_MAYTRONICS_BOX_MAC_ADDRESS
    id: maytronics_cover

sensor:
  - platform: ble_client
    type: characteristic
    ble_client_id: maytronics_cover
    id: needed_to_open
    name: "Needed to open"
    service_uuid: dfad4778-1b37-4241-b665-f66b2736b956
    characteristic_uuid: d92a2420-a036-41d5-b7d7-6161ce4cead3
    notify: true
  - platform: ble_client
    type: characteristic
    ble_client_id: maytronics_cover
    id: opening
    name: "Opening"
    service_uuid: dfad4778-1b37-4241-b665-f66b2736b956
    characteristic_uuid: 3bcc2430-f209-4055-9566-fcfe3ea27776
    notify: true

cover:
  - platform: template
    name: "Pool cover"
    lambda: |-
      if (id(opening).state == 16) {
        return COVER_CLOSED;
      }
      else {
        return COVER_OPEN;
      }
    open_action:
      - ble_client.ble_write:
          id: maytronics_cover
          service_uuid: dfad4778-1b37-4241-b665-f66b2736b956
          characteristic_uuid: 8bcc63e3-f209-4055-9566-fcfe3ea27776
          value: [0xcb,0x2c,0x7c,0x7c,0x17,0x1f,0x1e,0x75,0x5a,0x11,0x09,0xdc,0x32,0x6c]
    close_action:
      - repeat:
          count: 10
          then:
            - ble_client.ble_write:
                id: maytronics_cover
                service_uuid: dfad4778-1b37-4241-b665-f66b2736b956
                characteristic_uuid: 8bcc63e3-f209-4055-9566-fcfe3ea27776
                value: [0xcb,0x2c,0x7c,0x7c,0x17,0x1c,0x1e,0x75,0x5a,0x11,0x09,0xdc,0x32,0x6d]
            - delay: 1s
    optimistic: true