Fabian-Schmidt / esphome-victron_ble

Use official Victron BLE endpoint for fetching data from Victron devices via Bluetooth LE via ESPHome.
GNU General Public License v3.0
152 stars 15 forks source link

cannot enable filters on some of the sensors #43

Closed pavelw closed 5 months ago

pavelw commented 5 months ago

seems that some sensors cannot be filtered.

image

text_sensor:

for other sensors it works correctly:


filtering is useful to reduce amount of reported data - load on wifi and mqtt systems. if not this, then support for "update_interval" would be nice :)

==== operation info ESPHome 2023.12.9

component works for me on:

all devices work flawlessly but seems that esphome needs more than basic ESP32 for BLE in my config. works ok on ESP32-S3-WROOM-1-N16R8 module

pavelw commented 5 months ago

update_interval:

image

and the esphome docs mention it could be possible:

image

https://esphome.io/components/text_sensor/template.html

pavelw commented 5 months ago

I can make some PR with support of these functions, but I would need some example code.. started to search for that

Fabian-Schmidt commented 5 months ago

Hi,

The filters throttle_average and heartbeat are for sensor components and not for text_sensor. This is a function of ESP Home. See filters for sensors vs text_sensor:

If you want a throttle_average and heartbeat filter for text_sensor please submit a PR to the ESP Home project.

The component does not use update_interval as I don't control the communication. Whenever the Victron device submits a Bluetooth package and the ESPHome receives it an update is triggered. No reason for an update interval.

pavelw commented 5 months ago

Update interval is useful because it allows limiting the number of updates, reducing the amount of network traffic.

I do not expect anything, just explaining my point of view. thanks for the component, it works quite well as it is! :)

pavelw commented 5 months ago

Workaround to limit text_filters without update_interval implemented:

   - lambda: |-
        static std::string last;
        if (x == last)
          return {};
        last = x;
        return x;

found this at https://community.home-assistant.io/t/send-template-text-sensor-state-to-ha-only-at-change/568655/18 in current form, will not publish update if it is the same value as previous one.

seems it can be easily improved, probably "hearbeat" and "throttle_average" code can be ported from esphome filter.cpp