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

Export network output sensor #46

Closed admiralroflknife closed 2 months ago

admiralroflknife commented 4 months ago

I have 3 Victron Mptt controllers networked together and the app provides a network output value. Is there a way to parse this to help reduce the message overhead and let Victron do the calculation instead of home assistant?

Fabian-Schmidt commented 4 months ago

I cannot access the Victron Network data. Instead you can create a esphome template sensor and aggregate the data on the device so you only submit a summary.

Fabian-Schmidt commented 4 months ago

Here is an untested example how such template sensor could look like.

sensor:
  - platform: template
    update_interval: 30s
    lambda: |-
      float solar_CURRENT = 0.0f;
      if(!std::isnan(id(solar15_BATTERY_CURRENT).state)) {
        solar_CURRENT += id(solar15_BATTERY_CURRENT).state;
      }
      if(!std::isnan(id(solar20_BATTERY_CURRENT).state)) {
        solar_CURRENT += id(solar20_BATTERY_CURRENT).state;
      }
      if(!std::isnan(id(solar50_BATTERY_CURRENT).state)) {
        solar_CURRENT += id(solar50_BATTERY_CURRENT).state;
      }
      return solar_CURRENT;

Afterwards you can set the original sensor to internal: true. Internal components will not be exposed to the frontend (like Home Assistant).