Integrate openWB Wallbox via MQTT

Hello,

after some struggle I was finally able to integrate the openWB into Home Assistant via MQTT. For my fellow openWBlers I wanted to document the status here.

  1. Have MQTT set up from the addon store
  2. Have SSH access to HA
  3. create a openwb.conf file under /share/mosquitto with belows content
  4. Restart mosquitto and check if you find in the logs Connecting bridge openwb (your.ip.of.openwb:1883)
  5. check with a MQTT (e.g. MQTT Explorer) client of the data arrives in MQTT

I hope you find this useful.

openwb.conf

connection openwb
address your.ip.of.openwb:1883
topic openWB/# both 2
local_clientid rem.mosquitto

config.yaml

sensor:
  - platform: mqtt
    name: "openWB Stellplatz Charged Since Plugged"
    state_topic: "openWB/lp/2/kWhChargedSincePlugged"
    unit_of_measurement: "kWh"
    device_class: energy
  - platform: mqtt
    name: "openWB Stellplatz Zähler"
    state_topic: "openWB/lp/2/kWhCounter"
    unit_of_measurement: "kWh"
    device_class: energy
  - platform: mqtt
    name: "openWB Stellplatz Leistung"
    state_topic: "openWB/lp/2/W"
    device_class: power
    unit_of_measurement: "W"
  - platform: mqtt
    name: "openWB Stellplatz Strom Phase 1"
    state_topic: "openWB/lp/2/APhase1"
    unit_of_measurement: "A"
  - platform: mqtt
    name: "openWB Stellplatz Strom Phase 2"
    state_topic: "openWB/lp/2/APhase2"
    unit_of_measurement: "A"
  - platform: mqtt
    name: "openWB Stellplatz Strom Phase 3"
    state_topic: "openWB/lp/2/APhase3"
    unit_of_measurement: "A"
  - platform: mqtt
    name: "openWB Stellplatz Phasen in Benutzung"
    state_topic: "openWB/lp/2/countPhasesInUse"
    unit_of_measurement: ""
  - platform: template
    sensors:
      openwb_ladeparameter:
        friendly_name: "openWB Stellplatz Ladeparameter"
        unit_of_measurement: ''
        value_template: >-
          {{ 
            states('sensor.openwb_stellplatz_leistung') | int / 1000 | float | round(1)
          }}kW/({{
            states('sensor.openwb_stellplatz_phasen_in_benutzung') | int 
          }}){{ 
            [
              states('sensor.openwb_stellplatz_strom_phase_1') | float,
              states('sensor.openwb_stellplatz_strom_phase_1') | float,
              states('sensor.openwb_stellplatz_strom_phase_1') | float
            ] | max | round(0)
          }}A

As the Audi SOC detection from openWB is not working atm I configured the MQTT SOC and created

  - alias: "Audi - Link SOC from Audi Integration to openWB"
    id: 6137bd88-e910-4149-a6e1-c96124c15177
    trigger:
      - platform: state
        entity_id: sensor.angelina_state_of_charge
    action:
      - service: mqtt.publish
        data_template:
          topic: 'openWB/set/lp/2/%Soc'
          retain: true
          payload: "{{ states('sensor.angelina_state_of_charge') | int }}"
2 Likes

Don’t forget to activate the custom folder in mqtt config before.

customize:
  active: true
  folder: mosquitto

Also if you only have one OpenWB you would use the topic openWB/lp/1 instead of 2.

Hallo Ralf
Deine Aufstellung ist sehr instruktiv. Ich bin ziemlicher Newbie in MQTT und Home Assistant und hoffe auf deine Hilfe.
Ich habe den Mosquitto erfolgreich konfiguriert und gestartet. Im Log sehe ich zumindest keinen Fehler beim Start des Brokers und der Einbindung der openWB als Client. Im UI des Mosquitto kann ich vmtl nur 1Topic publizieren bzw abonnieren. Wahrscheinlich muss ich dafür ein Script erstellen. Hast du Beispiele vor allem für die Bezeichnung der openWB-Daten als Topic.
Im openWB Status/mqtt Log sehe ich möglicherweise die korrekten Bezeichnungen, unter denen openWB Daten publiziert werden, zB. RequestYearGraphv1 Message oder nur YearGraphv1
Ich hoffe, dass du oder evtl jemand anderes mit derselben Thematik den alten Thread wieder aufnimmt.
Kurz gesagt:
wo kann ich die korrekten Topic-Bezeichnungen entnehmen?
wo kann ich sie publizieren oder abonnieren?
wie kann ich die Daten und Schalter der openWB in Home Assistant sichtbar machen?

Is this what you are looking for?

https://openwb.de/forum/viewtopic.php?t=577

This might be relevant too

Thanks for reply. This seems to be the missing information.
Hope to get trough sucessfully.
kr
Adi

Hi Ralf, sorry to bother you again. I’m not familiar with writing scripts but try to get in. I had integrated Mosquitto successfully. The log doesn’t show errors. I also integrated openwbmqtt via HACS and it seems to work. I hope you have certain experience of openwbmqtt integration.
In lovelace I see most of the openWB sensors except the button to control the charge mode. However there is a note >unknown< and no data behind the sensor. I think this note is a result of a bad configuration of the topics. The openWB bridge is active. Prefix is >openWB/<.
I the folder >config/custom_components/openwbmqtt/translations< I’ve modified the file de.json according to the openWB prefix, host and number of charge points.
I’m in doubt if I should use unsafe port 1883 or safe port 8883.
However using 1883 as well as 8883 leads to the same note >unknown< in Lovelace.
When I have an look into the mqtt- traffic by mqtt-explorer I see the original data of the openWB/lp/1.
For safe port 8883 I’ve already installed Duck-DNS and NGINX. They started successfully as well.
I’m a bit confused about the publishing and subscription of the openWB data and assume that these improper settings might lead to the note >unknown< in lovelace. I don’t know where I have to modify the topic entry.
It would be great to get some support and try to learn. Thanks a lot in advance.

Did you solve that issue ? Have the same problem on my end.
Installed and configured everything like described, but got only >unknown< for the sensor values.
Have double checked the Enty in config.storage\core.config_enties:

        {
            "entry_id": "7c5ef5fa3fa3b69a3c36350f0b4a832e",
            "version": 1,
            "domain": "openwbmqtt",
            "title": "openWB/",
            "data": {
                "mqttroot": "openWB/",
                "chargepoints": 1,
                "host": "192.168.178.52"
            },
            "options": {},
            "pref_disable_new_entities": false,
            "pref_disable_polling": false,
            "source": "user",
            "unique_id": "openWB/",
            "disabled_by": null
        }

which should be correct.

And I got all the MQTT values if I use an client (MQTT Fx) and subscribe to openWB/#
but not in the integraten !??

I’m a little bit lost now. Maybe someone here can help.

Got it running, the / was to much. Sometimes you have to have a second pair of eyes.

Got a Tesla recently.

M3SR needs to be charged once a week to 100%. I wanted to automate the “max charging SOC” via the openWB … and … works like a charm.

FYI .The SOC form the tesla I get into HA via TeslaMate and do send it out to openWB similar to the Audi one in the 1st post.

I added the following automation and … et voilat … SocChargingTo is set at 9am every morning to 80% except for Thursdays where it is set to 100%.

  - alias: "openWB - at 9am set socToChargeTo on 80% but Thursdays to 100%"
    trigger:
      - platform: time
        at: "09:00"
      - platform: homeassistant
        event: start
    action:
      - service: mqtt.publish
        data_template:
          topic: "openWB/config/set/sofort/lp/1/socToChargeTo"
          retain: true
          payload: "{{ (80 + 20 * (now().weekday() in [3])) | int }}"

Doing so I dont need to take care anymore. Just plug it in every evening and HA takes care. This is what automations habe to look like IMHO.

Be carefull with other Tesla models. Most of them require to set the SocChargingTo to 80% normally and only set it to 100% if you really need the extra miles. But you get the jist.

You could create an automation which sets the SocChargingTo to 100% when pressing a button … or when you have an event in your calender the next day with an address more far away than 400 miles … the options are endless.

Only when you have those options to connect all the different appliances … you get thinking about whats possible and push the boundaries.

Have fün …
Ralf

Hi all,

I just want to share the “openWB” Integraition again with you :slight_smile:

this was already mentioned in a comment above… but the integration does provide a couple of sensors more since it was created initially…

personally, I had some issues with the integration - as long as I used the “Mosquitto Broker” addon acting as a bridge between HomeAssistant and the Broker on the OpenWB…

Now, I have connected MQTT directly to the Broker on the OpenWB which seems to be more reliable than using the bridged-broker… :slight_smile:

The issue I had was that the Bridged broker sent old data to HomeAssistant after rebooting HomeAssitant (for example, due to updates, or what ever)…

I am using the openWB integration. Works like a charm. Thanks for sharing.

If you are wondering how to integrate multiple openWBs into your installation, you have to adjust your custom mosquitto config and define multiple connections and remap the topic trees, like this:

connection openwb1
address <hostname or ip of your first openWB>:1883
start_type automatic
topic # both 2 openWB1/ openWB/
local_clientid openwb1.mosquitto
try_private false
cleansession true

connection openwb2
address <hostname or ip of your second openWB>:1883
start_type automatic
topic # both 2 openWB2/ openWB/
local_clientid openwb2.mosquitto
try_private false
cleansession true

Then configure the openwbmqtt integration two times using openWB1 and openWB2 as root Topics.

For debugging purposes i can recommend using mqtt-explorer to gain insight into your Homeassistant and openWB brokers.

1 Like

that only works if you are using the MQTT Broker in HomeAssistant as a Bridge.
In my case, I don’t use this configuration - and have connected the MQTT Integration directly to the broker of the OpenWB - in that case, your configuration would not work, but it might work while using the OpenWB (1) Broker and OpenWB (2) Broker in Bridged mode… ?!
Or - you could set the openwb 2 into “only chargepoint” mode and fully controll it through the other OpenWB…

I have two OpenWBs. Both are connected and they do load management between them. I have connected master OpenWB to HA and can see both wall boxes in HA using the openwb integration.

I cannot get the openWB integration to connect to the openWB. I get all the entities, but they all have “unknown” state. I’ve seen others report the problem, but the solution was never published. Can someone help me out on this please?
I can connect successfully with the MQTT explorer, but mqtt sub -t /# -h <openWB-IP> -V 3 does not report anything. Is it normal I have to select protocol version 3?

1 Like

It is working now out of a sudden, but I am uncertain why. It seems related to a restart. I tried restarting previously, but maybe HA had to be restarted several times.
mqtt sub still does not report any topics of openWB (but that was just for checking, so I don’t care).