Repository navigation
How to send meter readings from homeassistant to cFos Wallbox? #89
Description
Activity
I am sending my meter values via HTTP POST request using Node-Red. Should also be possible directly from HA.
http://CFOS-IP/cnf?cmd=set_ajax_meter&dev_id=M4Take a look at the cFos documentation.
As I integrated my wallbox in HA Modbus integration inside cfos Wallbox wasn't working well. So I am stuck with HTTP requests.
Hi @wmader23,
I am already using the REST endpoints of the cfos wallbox, which you could also reuse. This calls every 15 seconds (is the same interval as for modbus) the endpoint of the cfos wallbox and updates the meter values.
# Configure RESTful Command rest_command: send_wallbox_meter_data: # dev_id can differ url: http://<ip>/cnf?cmd=set_ajax_meter&dev_id=M4 method: post username: <username> password: <password>> content_type: application/json # don't verify ssl as it's selfsigned verify_ssl: false # right now I am calculating the export/import of energy and sending to the wallbox, can also be splitted in different calls. You could just adapt this script. payload: '{ "power_w": {% if states("sensor.solax_grid_import") | float(default=0.0) - states("sensor.solax_battery_power_charge") | float(default=0.0) > 0 %} {{ states("sensor.solax_grid_import") | float(default=0.0) - states("sensor.solax_battery_power_charge") | float(default=0.0) }} {% else %} {{ states("sensor.solax_grid_export") | float(default=0.0) | multiply(-1) }} {% endif %} }' # '{ "power_w": {{ states("sensor.solax_grid_export") | float(default=0.0) | multiply(-1) }} }' #payload: '{ "export_wh": {{ states("sensor.solax_grid_export") }}, "current": [{{ states("sensor.solax_inverter_current_l1") | float(default=0.0) | multiply(1000)}}, {{ states("sensor.solax_inverter_current_l2") | float(default=0.0) | multiply(1000)}}, {{states("sensor.solax_inverter_current_l3") | float(default=0.0) | multiply(1000)}}]}' automation: - alias: "Send Data to Wallbox" trigger: platform: time_pattern seconds: "/15" action: service: rest_command.send_wallbox_meter_data ```
Hei, thank your for the code snipped!
Hi,
thanks for building the homeassistant integration.
There is an action powerbrain.set_meter. Testing is possible under Developer Tools > Actions
Parameters are also listed there, but I think it doesn't work anymore. My cFos Power Brain only reacts to"power**_w**" instead of "power". Parameter seems to be changed in year 2023 by cfos.
@mb-software Can you update the code?The
set_meterservice does exactly this. PR #92 adds proper documentation in the README.Example — send readings from a HA sensor to cFos HTTP input meter
M1:service: powerbrain.set_meter data: dev_id: M1 power: "{{ states('sensor.battery_power') | int }}" import_energy: "{{ states('sensor.battery_import_energy') | float }}" export_energy: "{{ states('sensor.battery_export_energy') | float }}" current_l1: "{{ states('sensor.battery_current_l1') | float }}" voltage_l1: 230
Make sure the meter in cFos is set to type HTTP Input.
@guibrazlima Thanks for your help and creating the fork!
set_meter is still not working in all because the paramater needs to be "power_w" instead of "power_va" or "power". It is also mentioned in the documentation: https://www.cfos-emobility.de/en/cfos-power-brain/http-api.htmdev_id: M4 power: "{{ states('sensor.smart_meter_aktuelle_gesamtwirkleistung') | int }}" import_energy: "{{ states('sensor.smart_meter_positive_gesamtwirkenergie') | float }}" export_energy: "{{ states('sensor.smart_meter_negative_gesamtwirkenergie') | float }}"results in:
But...
http://192.168.178.11/cnf?cmd=set_ajax_meter&dev_id=M4&power_w=1234&import_wh=1000&export_wh=50In init.py Line 76 needs to be changed into:
data["power_w"] = call.data.get("power")Tested and it works:


Modbus usually allows to connect a server to only one client. Such the case for my battery and my inverter.
I have all meter readings of battery and inverter integrated in homeassistant via the sunspec and varta (specific to my battery) integration.
The bullet point
"Adds a Homeassistant service to send power meter values to an HTTP input meter in the charging manager"
from the README of this integration seems to indicate, that it can be used to sending meter readings from ha to the wallbox. However, I don't know how to do that.
If we can work this out together I will create a PR to update the documentation.
Thanks!