a529987659852 / openwb2mqtt

Home Assistant Integration for openWB (Version 2)
9 stars 3 forks source link
home-assistant home-assistant-custom home-assistant-integration

openWB2 with Home Assistant

This is a custom component for Home Assistant supporting the openWB wallbox for charging electric vehicles. The integration subscribes to MQTT topics which are used by openWB to broadcast information and displays this informations as entities. You can also change, for example, the charge mode of a charge point.

Note: I provide this custom integration without any warranty. It lies in the responsability of each user to validate the functionality with his/her own openWB!

This integration assumes that you run the openWB using software version 2.x. If your wallbox still uses the version 1.9x, please use the older version of this integration (https://github.com/a529987659852/openwbmqtt).

If you need help, also have a look here. Although created for the previous version of this integration, you should still find useful information if you're not familiar to MQTT and/or custom integrations in Home Assistant.

What does the custom integration provide?

My integration provides the following device types:

How to add this custom component to Home Assistant

Step 1: Deploy the Integration Coding to Home Assistant

Option 1: Via HACS

Make sure you have HACS installed. Under HACS, choose Integrations. Add this repository as a user-defined repository.

Option 2: Manually

Clone the custom component to your custom_components folder.

Step 2: Restart Home Assistant

Restart your HA instance.

Step 3: Add and Configure the Integration

In HA, choose Settings -> Integrations -> Add Integration to add the integration. HA will display a configuration window. For details, refer to the Example Configuration section

Example Configuration for openWB2

When setting up this integration, you must choose the device type to be created and provide additional details (MQTT root and device ID).

How to find out the device ID and MQTT root?

This image shows an example of the MQTT topics published by openWB2 and how to identify the MQTT root topic

HowToConfigureChargePoint-MQTT

This image shows the openWB2 status page (http://your-ip/openWB/web/settings/#/Status) and the device IDs: HowToConfigureChargepoint-Status

Additional Information: How to get the openWB values from the wallbox into Home Assistant using MQTT

TLDR: Use the file mosquittoExampleConfiguration.conf contained in this repository to configure your eclipse MQTT server to import data from the openWB MQTT server and to send data to it. Don't forget to change IP address and device ID(s).

From a technical perspective, this integration uses an MQTT server to obtain the data from the wallbox. The wallbox itself has its own MQTT server. Depending on your network setup, you have two options:

Let's disuss the second option in more detail.

To establish a bridge, you can either start on the openWB-MQTT and export values to the HA-MQTT. This can be set up in the webinterface of openWB. Go to section Einstellungen -> System -> MQTT-Brücken and make the necessary settings. Since I'm not using this approach, I cannot give you additional hints.

Alternatively, you can start on the HA-MQTT and subscribe to topics on the openWB-MQTT. To do this, you have to change the configuration file of the MQTT server. I'm using the Mosquitto MQTT server. This is also the server you run if you're using the Home Assistant MQTT addon. To subscribe to other MQTT servers in Mosquitto, navigate to the config folder of Mosquitto, create a sub-directory conf.d (if it does not already exist), and create a file openWB.conf. In the file, you configure your bridge. See the following example:

#
# bridge to openWB Wallbox
#
connection openwb2
local_clientid openwb2.mosquitto

#TODO: Replace IP address
address 192.168.0.68:1883

#Sensors Controller
topic openWB/system/ip_address in
topic openWB/system/version in
topic openWB/system/lastlivevaluesJson in

#Sensors per Chargepoint
#TODO: Replace 4 by your chargepoint ID
topic openWB/chargepoint/4/get/# in
topic openWB/chargepoint/4/config in

You must change the following:

Then save the file and restart Mosquitto. You should now see MQTT topics with values coming from the openWB-MQTT server.

Note: The example configuration is not complete. Please refer to the file mosquittoExampleConfiguration.conf in this repository which contains a fully running example. Just don't forget to adapt the device IDs!

The configuration option in in each topic line takes care that data from the openWB-MQTT server is only imported to the HA-MQTT. Therefore, entities you can change in Home Assistant (for example number entity for manual SoC, selector for change mode, and selector for connected vehicle) don't not work, yet. Let's look into the following section of the example configuration:

#Selects per Chargepoint
#TODO: Replace 4 by your chargepoint ID
topic openWB/chargepoint/4/get/connected_vehicle/config in
topic openWB/set/vehicle/template/charge_template/+/chargemode/selected out

The last line exports a topic FROM the HA-MQTT server TO the openWB-MQTT server by specifiying the out option. This topic is populated by Home Assistant when you change the Chargemode on the UI, for example from PV Charging (PV-Laden) to Instant Charging (Sofortladen).

Note: The example configuration is not complete. Please refer to the file mosquittoExampleConfiguration.conf in this repository which contains a fully running example. Just don't forget to adapt the device IDs!

Additional Information: Which MQTT topics refer to which entities in Home Assistant

Check the file MQTT-Topics.txt in this repository for more information.

How ro read this file?

Let's investigate the following example entry:

SENSORS_PER_CHARGEPOINT
       mqttTopicCurrentValue = {mqttRoot}/chargepoint/{deviceID}/{key}
               key="get/power",

For the device chargepoint, there is a sensor that subscribes to the MQTT topic

                {mqttRoot}/chargepoint/{deviceID}/get/power
# For example:  openWB    /chargepoint/0         /get/power

If you want to know to which sensor entity this MQTT topic is mapped, have a look into the file const.py.

Check the list SENSORS_PER_CHARGEPOINT and locate the entry with key="get/power".

The property name corresponds to the entity name in Home Assistant. In our example, the topic above is mapped to the sensor Ladeleistung of the device chargepoint.