MQTT Topics for Home Assistant#

Topics used for communication between GbbOptimizer and Home Assistant / GbbConnect.

Data from Home Assistant to GbbOptimizer#

Required fields:

FieldTypeDescription
soc_percdecimalBattery SOC (%). Use V if “Control via V” is checked
loads_total_kWhdecimalConsumption — cumulative counter
fromgrid_total_kWhdecimalGrid import — cumulative counter
togrid_total_kWhdecimalGrid export — cumulative counter
pv_total_kWhdecimalPV production — cumulative counter

Optional fields:

FieldTypeDescription
ev_charge_total_kWhdecimalEV charging
hp_total_kWhdecimalHeat pump
other1_total_kWhother6_total_kWhdecimalOther 1–6

Multiple PV sources:

1
2
3
4
5
6
7
{
  "pv_total_kWh": 123.4,
  "more": [
    {"number": 2, "pv_total_kWh": 56.7},
    {"number": 3, "pv_total_kWh": 89.0}
  ]
}
  • Counters may reset — you can send daily counters for example
  • Values < 0 are treated as missing data
  • You can send only optional data if the main data is imported from the inverter. In that case add the HomeAssistant system in the IoT menu
  • pv_total_kWh is the same as "more" with number=1 — do not use both at the same time
  • Solarman/DeyeCloud: individual fields (soc_perc, fromgrid_total_kWh, togrid_total_kWh, loads_total_kWh) can be sent separately if the corresponding options are checked in installation parameters

Commands from GbbOptimizer to Home Assistant#

GbbOptimizer sends control commands to dedicated topics:

PUB {PlantId}/ha_gbb/Start_Charge

Start charging battery to SOC from Payload

PUB {PlantId}/ha_gbb/Start_Discharge

Start discharging battery to grid (to SOC from Payload)

PUB {PlantId}/ha_gbb/Start_DisableCharge

Do not charge battery — PV to home and grid

PUB {PlantId}/ha_gbb/Start_Normal

Return to normal operation

In parallel, the same data is sent to:

PUB {PlantId}/ha_gbb/EMS

Combined EMS command with full JSON payload

JSON Payload:

FieldTypeDescription
HourintHour
FromMinuteintStart minute
ToMinuteintEnd minute
DischargeLimitWintDischarge limit (W)
ChargeLimitWintCharge limit (W)
InputLimitWintImport limit (W)
PriceLessZeroint0 = normal price, 1 = price < 0
Operationstring"Normal", "Discharge", "DisableCharge" or "Charge"
SOCintTarget SOC
VdecimalSOC converted to V (if control via V)

Example:

1
2
3
4
5
6
7
8
{
  "Hour": 22,
  "FromMinute": 0,
  "ToMinute": 59,
  "PriceLessZero": 0,
  "Operation": "Normal",
  "SOC": 90
}

HA Automation Example#

1
2
3
4
5
6
7
8
alias: mqtt output_source_priority_battery
trigger:
  - platform: mqtt
    topic: ha_gbb/Start_Charge
action:
  - service: switch.turn_on
    target:
      entity_id: switch.bms_1_output_source_priority_battery

Example: Publishing Data to MQTT#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
alias: mqtt_publish
trigger:
  - platform: time_pattern
    minutes: /5
action:
  - service: mqtt.publish
    data:
      qos: "0"
      retain: false
      topic: ha_gbb/sensor
      payload: >
        {
          "loads_total_kWh": {{ states.sensor.inverter_out_daily_energy.state | float(-1) }},
          "fromgrid_total_kWh": {{ states.sensor.inverter_in_daily_energy.state | float(-1) }},
          "pv_total_kWh": {{ states.sensor.total_daily_energy.state | float(-1) }},
          "soc_perc": {{ states.sensor.battery_soc.state | float(-1) }},
          "togrid_total_kWh": 0
        }