Hello to All,
I (old man started with Home Assistant and learning slowly) try to implement MQTT sensors for monitoring (and control) my OpenWB Pro wallbox.
While reading through this community I figured out a lot of useful ways of implementation. But now I am stuck with following topic:
I would like to SET (means send) a value to the wallbox. Reading FROM the wallbox is working well, I can get all values I need. But writing a value is still like a riddle for me. Please see below mentioned code sniped from my CONFIGURATION.YAML:
> mqtt:
> sensor:
> # ------- mqtt onpenWB Collection -------
> # Get SoC from Renault Zoe
> - state_topic: "openWB/vehicle/1/get/soc"
> name: "OpenWB SoC read"
> value_template: "{{ value | float(0) | round(0) }}"
> device_class: battery
> # Get Chargemode
> - state_topic: "openWB/vehicle/template/charge_template/1"
> name: "OpenWB Chargemode read"
> value_template: "{{ value_json.chargemode.selected | replace('pv_charging', 'PV-Laden') | replace('instant_charging', 'Sofortladen') | replace('stop', 'Stop') }}"
> # Set Chargemode
> - command_topic: "openWB/set/vehicle/template/charge_template/1"
> name: "OpenWB Chargemode write"
> value_template: "{{ value_json.chargemode.selected }}"
> payload: "4"
The first two topics are working fine (just pull values from the wallbox). But the last topic (set a topic in the wallbox with a defined value) is giving me Errors while re-loading the YAML-file. So, it seems like a syntax error - but I do not have a clue.
Can some friendly soul give me please a hint or advice what to do?
Thanks in advance
HAMausepaul
Update:
Currently I am getting a (not in the way I wanted) topic set in my wallbox. See code below:
mqtt:
sensor:
# ------- mqtt onpenWB Collection -------
# Get SoC from Renault Zoe
- state_topic: "openWB/vehicle/1/get/soc"
name: "OpenWB SoC read"
value_template: "{{ value | float(0) | round(0) }}"
device_class: battery
# Get Chargemode
- state_topic: "openWB/vehicle/template/charge_template/1"
name: "OpenWB Chargemode read"
value_template: "{{ value_json.chargemode.selected | replace('pv_charging', 'PV-Laden') | replace('instant_charging', 'Sofortladen') | replace('stop', 'Stop') }}"
switch:
# Set Chargemode
- command_topic: "openWB/set/vehicle/template/charge_template/1"
state_topic: "openWB/vehicle/template/charge_template/1"
name: "OpenWB Chargemode write"
value_template: "{{ value_json.chargemode.selected | 'pv_charging' }}"
payload_on: "pv_charging"
But the problem is that I am not “hitting” the right target value. Instead I am “creating” new topiv/value in my wallbox.
Does anybody has a clue about the right way of doing it?
For reference here is a screenshot of the topic I am talking about in MQTT Explorer:
Thanks for your help
HAMausepaul
Update 2 (for those who are insterested):
I created a mqtt.yaml file with following code - and it works. So I can use this as a start for implementing more needed functionality:
sensor:
# ------- mqtt onpenWB Collection -------
# Get SoC from Renault Zoe
- name: "OpenWB SoC read"
state_topic: "openWB/vehicle/1/get/soc"
value_template: "{{ value | float(0) | round(0) }}"
device_class: battery
# Get Chargemode
- name: "OpenWB Chargemode read"
state_topic: "openWB/vehicle/template/charge_template/3"
value_template: "{{ value_json.chargemode.selected | replace('pv_charging', 'PV-Laden') | replace('instant_charging', 'Sofortladen') | replace('stop', 'Stop') }}"
switch:
# Set Chargemode STOP
- name: "OpenWB Chargemode write stop"
command_topic: "openWB/set/vehicle/template/charge_template/3/chargemode/selected"
payload_on: "stop"
payload_off: "stop"
# Set Chargemode PV-LADEN
- name: "OpenWB Chargemode write pv_charging"
command_topic: "openWB/set/vehicle/template/charge_template/3/chargemode/selected"
payload_on: "pv_charging"
payload_off: "pv_charging"
# Set Chargemode SOFORTLADEN
- name: "OpenWB Chargemode write instant_charging"
command_topic: "openWB/set/vehicle/template/charge_template/3/chargemode/selected"
payload_on: "instant_charging"
payload_off: "instant_charging"
In case of any questions I am happy to help.
Cheers
HAMausepaul