syssi / esphome-jk-bms

ESPHome component to monitor and control a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE
Apache License 2.0
403 stars 134 forks source link

Total Current for multiple JK BMS devices #490

Open Benthegreat opened 3 months ago

Benthegreat commented 3 months ago

How would you combine two JK BMS values together? I am using your esp32-example-multiple-devices code and two esp32-example-faker code. Every option I have tired I get errors like not declared in scope.

thegoloone commented 2 months ago

I would try to add an id for the sensor I want to calculate.

    current:
      name: "bms1 current"
      id: bms1_current

And add another sensor that calculates like

  - platform: template
    name: Total Current
    unit_of_measurement: "A"
    accuracy_decimals: 0
    state_class: measurement
    lambda: |-
      return (id(bms1_current).state + id(bms2_current).state);
    update_interval: 5s
    device_class: energy