Skip to main content
Version: 4.2.12

Home Assistant & MQTT

Your EMS runs its own MQTT broker on your home network. Home Assistant (or another home automation system) can use it to read your energy data live and control a limited set of functions. Everything stays local: nothing goes over the internet.

Connecting​

SettingValue
BrokerThe IP address of your EMS on your home network
Port1883 (plain) or 8883 (encrypted with TLS)
Usernameautomation
PasswordUnique to your device, see below

Example for Home Assistant (configuration.yaml, or through the MQTT integration in the settings):

mqtt:
broker: 192.168.1.50 # IP address of your EMS
port: 1883
username: automation
password: <your password>

Your password​

Every device has its own random password. Ask your installer or our support for it, and give your installation number.

Old passwords no longer work

The password used to be derived from your device number (for example EMS-501-mqtt-2025). For security reasons it has been replaced by a random password per device. If your integration worked until a recent update and now reports "not authorised" or "connection refused", ask for your new password.

Keep your password to yourself: anyone who knows it can control your charger and home battery from your home network.

Reading data​

Connect with a tool such as MQTT Explorer to see every topic and its live value. The most useful ones are under sensor/<id>/, where <id> is the number of your installation as shown in MQTT Explorer:

TopicMeaningUnit
sensor/<id>/netGrid powerkW
sensor/<id>/pvSolar powerkW
sensor/<id>/batBattery powerkW
sensor/<id>/socBattery level%

Power is always in kW, not W.

EMS status (read only)​

Besides sensor/#, you can follow what the EMS decides and what you set in the portal. You can only read these topics: you change them in the portal or with the commands below, not by sending something to them yourself. The content is JSON.

TopicWhat you seeWhen it appears
state/charger_connectedWhether a car is plugged into your charger (connected: true or false)If you have a charger; updated every 2 minutes
state/charger_user_overrideWhether your own charging choice (portal or MQTT) takes priority over your charging planOnly if you have a charging plan
state/curtailing/pv_budget_wHow much solar power (in W) the EMS allows when it limits your panelsOnly while the EMS limits your panels, for example at negative prices
desired/charging_planYour charging plan as you set it in the portal (target time, target %, preference, days); null when there is no planWhen you change your charging plan in the portal
desired/ev_stateWhat the EMS knows about your car: battery level, capacity, maximum charging power and whether it is plugged inOnly if your car is linked through the portal

If you do not see a topic, the condition in the last column does not apply to you.

Controlling your charger​

The automation user may send these commands. They do the same as the matching choice in the portal (see EV charging).

TopicPayloadEffectPackage
charger/set_mode6Slim laden (Smart charging)Full, and only with a Day and night or Dynamic energy plan
2Zon + minimum (Solar + minimum)Always included
3Nu laden (Charge now)Light · Full
5Niet laden (Don't charge)Light · Full
charger/set_manualcurrent in A, e.g. 10Aangepast laden (Custom charging) at that fixed currentLight · Full
charger/set_number_of_phases1 or 3Number of phases; only works in Aangepast ladenLight · Full
car/SoCbattery level in %, e.g. 64Tells the EMS how full your car is (for example from your car's integration in Home Assistant)

A mode you choose through MQTT counts as your own choice: a charging plan from the cloud does not overwrite it.

Example: a Home Assistant script that switches to Charge now.

script:
ev_charge_now:
sequence:
- action: mqtt.publish
data:
topic: charger/set_mode
payload: "3"

Controlling your home battery​

Available in

Light · Full · see Packages

You can tell the EMS to charge or discharge your home battery at a fixed power for a while. This works for every inverter brand, even though the topic starts with sofar.

TopicPayloadEffect
sofar/setWorkingMode/passivepower in W, e.g. 3000Charge at 3000 W
negative power in W, e.g. -2500Discharge at 2500 W
0Ends your manual command: the EMS controls the battery again
  • The power is for your whole installation. With several inverters that have a battery, the EMS splits it across them.
  • Your command stays active until you send 0. Do not forget that at the end of your automation, or the battery keeps charging or discharging at that power.
  • The EMS may keep the power below what you asked, for example to respect your capacity tariff or because the inverter cannot deliver more.
  • Do not use sofar/setWorkingMode/auto to stop. It puts the inverter in its own built-in mode and does not end your manual command. Send 0 to sofar/setWorkingMode/passive: the EMS then takes the battery back.
  • Does your installation not react to your command? Then it still needs a software update. Please contact us.

Example: charge at 3000 W and hand control back to the EMS after one hour.

script:
battery_charge_1h:
sequence:
- action: mqtt.publish
data:
topic: sofar/setWorkingMode/passive
payload: "3000"
- delay: "01:00:00"
- action: mqtt.publish
data:
topic: sofar/setWorkingMode/passive
payload: "0"

Sending external solar power​

If you have panels on an inverter the EMS does not read itself, Home Assistant can send their power to sensor-ha/1, in W (e.g. 1850). The EMS counts it as solar power. Send it regularly, for example every minute, and use one topic only: each value replaces the previous one.

What you cannot control over MQTT​

Relays (for example a boiler or heat pump on a smart relay) cannot be switched on, off or to automatic over MQTT; use the portal for that. Every topic not listed above is blocked for writing or ignored, so a mistake in your home automation cannot disturb the energy control.

Troubleshooting​

  • "not authorised" or "connection refused" when connecting: the password is wrong. Ask for your current password (see above).
  • Connected, but some values or controls do nothing: your integration uses a topic that is not in the list above. Reading or writing it is refused.
  • No connection at all: check that Home Assistant and your EMS are on the same network and that you use the right IP address.