Victron Venus OS with MQTT sensors, switches and numbers

This is working perfectly!

So now next step: trying to write a message using MQTT. now trying to set the ESS gridpoint.
The only thing I need to do is send payload: {“value”: 0.0} for grid setpoint 0, {“value”: -100.0}, {“value”: 100.0} and so on.

As in the TCP example I have set up a slider for this input in configuration.yaml:

input_number:
  input_current_slider:
    name: ESS Grid Target Value
    min: -600 #update this to your maximum inverter capacity
    max: 600 #update this to your maximum inverter capacity
    step: 10 #this is the increment of the slider in watts.  It can be as low as increments of 10. 

And then I cant get the automation working:
need to send this payload to:
venus-home/W/VENUSSERIAL/settings/0/Settings/CGwacs/AcPowerSetPoint

This is what I have in my automations.yaml.
But the problem I think is that value is recognised in home assistant as something, but needs to be just parsed as text. Who with more MQTT knowledge can help?!

trigger:
  - platform: state
    entity_id: input_number.input_current_slider
    to:
action:
   - service: mqtt.publish
      topic: venus-home/W/VENUSSERIAL/settings/0/Settings/CGwacs/AcPowerSetPoint
      payload_template: "{"value": {{ trigger.to_state.state | round(1)}}}"

error message:

Error loading /config/configuration.yaml: mapping values are not allowed here
in "/config/automations.yaml", line 18, column 12```

Ok got it working:
Here’s my automation code for reference:

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - input_number.input_current_slider
condition: []
action:
  - service: mqtt.publish
    data:
      topic: venus-home/W/VENUSSERIAL/settings/0/Settings/CGwacs/AcPowerSetPoint
      payload: "{\"value\": {{ trigger.to_state.state | round(1)}}}"
alias: slider to victron

1 Like

Hi!

I haven’t tried this myself yet, so I might have understood this the wrong way. Sorry if so.

I was investigating how to get this to work outside if local LAN, and came across this:

It mentions the current MQTT Implementation to change, in favor for a better, smaller and faster way. Will this change affect the topic of this post in any way?

It seems it’s will. I think the biggest concern is it said broker to broker bridging does not work with Flash yet.

But there is this action item:
“Finish broker to broker connection implementation into FlashMQ (action @wiebeytec )”

So hopefully that will not break anything if mosquito broker can still bridge to flashmq in the future.

Looks like as long as we don’t update your cerbo firmware nothing will change even once it’s released out of testing. So hopefully this current way will stay working for a long time as long as you disable auto updates on your cerbo.

I’ve been using the MQTT integration successfully for a few months now monitoring and controlling what’s available, but there is one setting that doesn’t seem to come through as an Entity in my setup. I’m trying to set the Max Charge Current for my Solar Charger via Home Assistant. I can see the current setting through MQTT Explorer (victron/N/############/solarcharger/279/Settings/ChargeCurrentLimit), but I’ve never had to set up my own custom switch for any Victron settings before. Is there a way similar to the examples above to create a Switch or other Entity in HA that will allow me to set the maximum charging current along a continuum from 0 to 70 amps? Or at least to set a switch with custom Low, Medium, and High settings that I can use? Sorry if this is very basic, but I have no experience with JSON, etc. Thanks in advance.

I’ve been able to publish through MQTT and get the value to change in what I can see through MQTT Explorer, but the setting is not going through to the actual solar charger. Is it possible that a setting like this is hard-wired to be read-only by Victron? Or is there some type of access setting I need to enable somewhere to authorize the change to “flow through” all the way to the Victron device itself?

1 Like

replace victron/N/############/solarcharger/279/Settings/ChargeCurrentLimit with victron/W/############/solarcharger/279/Settings/ChargeCurrentLimit
So the /N/ is for reading, the /W/ is for writing the setting. Victron will read the setting and change the /N/ output. That way you see that the setting has actually changed.

Are the switches working for you? I have the last firmware version and any switch work. Example:

name: Max Discharge Power
command_topic: "victron/R/{myid}/settings/0/Settings/CGwacs/MaxDischargePower"
payload_on: '{"value": 1000.0}'
payload_off: '{"value": -1.0}'
state_topic: "victron/N/{myid}/settings/0/Settings/CGwacs/MaxDischargePower"
value_template:....

I tested before with W instead of R and also not working…

All sensors are working fine… Days with this stuff and I cannot find the issue

Solved, the issue was that I followed a tutorial where wss not defined de topic W in the bridge configuration

having the same problem, can you please share how should the victron.conf be?

Did you copy everything for a start?

the number input works fine:

number:
    
       - unique_id: multiplus_discharge_power
        name: Max discharge power
        min: 0
        max: 10000
        step: 50
        mode: box
        command_topic: "venus-home/W/your-victron-id/settings/0/Settings/CGwacs/MaxDischargePower"
        command_template: '{"value": {{ value }} }'
        state_topic: "venus-home/N/your-victron-id/settings/0/Settings/CGwacs/MaxDischargePower"
        value_template: >
          {% if value_json.value == -1 %}
            10000
          {% else %}
            {{value_json.value | round(0) }}
          {% endif %}
    
        device_class: power
        icon: mdi:battery-arrow-down-outline
        unit_of_measurement: W
        device: {
          identifiers: [
           "Victron Cerbo GX"
          ],
          manufacturer: "Victron Energy",
          model: "Cerbo GX",
          name: "Cerbo GX"}

Ok, now the W topic are beeing written, but when I change a number , for example
victron/W/48e7da865289/settings/0/Settings/CGwacs/BatteryLife/MinimumSocLimit
to for example 30 it’s value is changed to 30
but the value
victron/N/48e7da865289/settings/0/Settings/CGwacs/BatteryLife/MinimumSocLimit
does not change (stays at 10)

this also for other topics, do you know why? There is some protection somewhere?

I think mqtt must be enabled in venus OS. Did you check that the values are read properly from HA.

Sensors work correctly. I can see by MQTT Explorer all values under victron/N/# .
Problem is, when I want change any value, it creates victron/W/… but it has no influence to values in victron setting and in victron/N/# .

Thanks for your help.

Solved.
Problem was in MQTT broker, which didnt integrate file \share\mosquitto\victron.conf .
Because I created this file after Mosquitto instalation and configuration, I supposed file will be readed after Home Assistant restart. But it wasn’t. It was necessary go to Addons/Mosquitto , change the config, save and restart mosquitto. After that th config file in \share\mosquitto\ was readed and applied.

Thank you.

Morning, not sure if I’m doing something wrong, but everything was working till last week. So the sensor for the TimeToGo this is what I have based on the docs:

    # Estimated Time until battery is empty based on current load.
    # These calculations were copied from victrons code to mimic how they display it
    - name: "Battery Remaining"
      unique_id: "battery_remaining"
      icon: mdi:timer-sand
      state_topic: "victron/N/<hidden>/system/0/Dc/Battery/TimeToGo"
      value_template: >
        {% if value == '{"value": null}' %}
          ∞
        {% else %}
          {% set seconds = value_json.value | round(0) | int %}
          {% set days = (seconds / 86400) | round(0, 'floor') | int %}
          {% set hours = ((seconds - days * 86400) / 3600) | round(0, 'floor') | int %}
          {% set minutes = ((seconds - hours * 3600) / 60) | round(0, 'floor') | int %}

          {% if 2 > days >= 1 %}
            {{days}} Day
          {% elif days >= 2 %}
            {{days}} Days
          {% elif hours > 0 %}
            {{hours}} Hours
          {% elif minutes > 0 %}
            {{minutes}} Minutes
          {% else %}
            ∞
          {% endif %}
        {% endif %}
      device:
        {
          identifiers: ["Victron Cerbo GX"],
          manufacturer: "Victron Energy",
          model: "Cerbo GX",
          name: "Cerbo GX",
        } 

The sensor works, but by some reason when it goes from “time” back to null, the sensor state stays on the previous value that was a number, is anyone having the same issue? Seems it only started to happen recently, I tried recreate the sensor, add a new one and the same still happens. Looking at the MQTT this is what I have in the history.

image

But the sensor is at 10… .

image

Any idea what might be triggering this? Seems its ignoring the null…

Thanks

Seems it does not like the null anymore…

Thanks for the detailed description. As I’m new to HA, it really saved me a lot of time.

Due to my setup, I have to use HA in docker and therefore some steps are slightly different. Nevertheless, it’s working.

Just for my understanding, why is the MQTT-Bridge needed? While I worked on the setup, I also got messages directly from the CCGX as it runs a MQTT broker itself.

For all of you who don’t know how to setup the mqtt.yaml:

Hi.
first, i have to say, that everything works really good. Thank you for the guide.

I have the following problem. If my Pi with Venus OS doesn’t send any data because it’s not reachable, for example. In homeassistant the last values ​​are still shown to me.
How can you implement an availability query so that the sensors are displayed as unavailable in this case?

Unfortunately I can’t get it to work.

thank you