myhomeiot / esphome-components

A collection of my ESPHome components
Other
257 stars 25 forks source link

battery sensor publish to ble monitor #2

Closed marcelveldt closed 2 years ago

marcelveldt commented 2 years ago

Hi, great work on this, exactly what I was looking for!

One question though. Is there any modification needed on the HA ble_monitor component to get the battery values ? I used your example to publish them to the parse service but I don't see the battery sensor appearing in HA.

myhomeiot commented 2 years ago

@marcelveldt Thanks ;)

Yes, you need to modify ble_monitor, I add comment here. Currently ble_monitor can't create sensor when receives data so we can't ask to include this changes into ble_monitor because all other users will get battery sensor with unknown/unavailable state.

marcelveldt commented 2 years ago

Thanks, that was the missing piece of the puzzle. Maybe the HA component should create this sensor as soon as the first value is received. That way it will work for all users. If I have some spare time next week I'll see if I can PR that.

myhomeiot commented 2 years ago

@marcelveldt Battery sensor was added for all users with note in Passive BLE Monitor 6.3.0

marcelveldt commented 2 years ago

Yeah, I spotted that. I think this could be a cool project for creating a house wide sensor setup. Just have some bluetooth dongles and/or some ESPHome devices throughout the device and you have covered your whole house.

marcelveldt commented 2 years ago

BTW: Passing the devices from HA to the ESP is also possible with a service call:

api:
  services:
    - service: set_devices
      variables:
        mac_addresses: string
      then:
        lambda: id(blegateway).set_devices(mac_addresses);

I'm currently looking at the ble_monitor code to see if I can add some logic to auto detect the ESP's running the ble gateway and pass the devices list. That would be super cool and even more easy. Populate a list in BLE Monitor with all found backends (ESP's and/or USB dongles).

marcelveldt commented 2 years ago

@chemelli74 nice to see you here too :-)