Victron vs Smart Home

Victron vs Smart Home

In this post, we will show you how to read information from a photovoltaic power plant from the company Victron. We will connect to the Cerbo unit via MQTT. Based on these values, we can control various devices (heating, boiler, etc.) and prevent battery waste for large appliances when they don't need to run.

Hardware

Pi-Home - if you don't have it, see the section How to Do It

Victron FVE

Software

OpenHAB 3

Procedure:

1) Find the IP address of Cerbo on your router. Usually in the DHCP tab, for example, on MikroTik, go to IP-> DHCP Server -> Leases. In this example, it's 10.1.1.125

Router IP address Victron

2) Enter the IP in your browser and enable the MQTT Broker function in Settings -> Services.

Victron MQTT komunikace

3) In OpenHAB, in Settings -> Things, add a new MQTT Broker (New Thing -> MQTT -> MQTT Broker) and enter the Cerbo's IP address. Use "ccgx" as the identifier and name it, for example, MQTT CCGX

Victron MQTT Broker

4) Connect to Raspberry via SSH

ssh openhabian@RASPBERRY-IP-ADDRESS

5) Connect to Raspberry via SSH (our fictional OpenHAB IP is 10.1.1.125)

mosquitto_sub -h 10.1.1.125 -t "#"

If everything is working, you will get a VRM ID:

MQTT Victron

 

In the following sections, replace the ID with your own ID. Since MQTT on Cerbo goes to "sleep" every 60 seconds, we need to keep refreshing communication and tell it that someone is listening. For this, a simple rule in Rules directly in OpenHAB 3 UI is sufficient. Go to Rules, add a new rule, give it a name (e.g., Cerbo's Refresh), and use the following code:

 

triggers:
- id: "1"
configuration:
cronExpression: 0/30 * * * * ? *
type: timer.GenericCronTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: |
val actions = getActions("mqtt", "mqtt:broker:ccgx")
actions.publishMQTT("R/c0619*****/system/0/Serial", "")
logInfo("Solar", "CCGX MQTT Keep Alive Timer fired!!")
type: script.ScriptAction

 Select Save. Then you can create a new Thing for each item you want to read into OpenHAB. Again, go to Settings -> Things, and using the + icon, create a new one. Fill it out according to the following pattern. Don't forget to choose the MQTT Victron in the MQTT Broker that you created earlier.

Victron MQTT items

After creating it, expand the Code tab where you can copy the following channels:

UID: mqtt:topic:pihome:vitronthings
label: Victron Things
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:ccgx
channels:
  - id: pv_battery_soc
    channelTypeUID: mqtt:dimmer
    label: Battery SoC
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Dc/Battery/Soc
      transformationPattern: JSONPATH:$.value
  - id: pv_battery_temp
    channelTypeUID: mqtt:dimmer
    label: Battery Temperature
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Dc/Battery/Temperature
      transformationPattern: JSONPATH:$.value   
  - id: pv_battery_state
    channelTypeUID: mqtt:dimmer
    label: Battery State
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Dc/Battery/State
      transformationPattern: JSONPATH:$.value         
  - id: pv_battery_voltage
    channelTypeUID: mqtt:number
    label: Battery Voltage
    description: null
    configuration:
      formatBeforePublish: "%.4f"
      stateTopic: N/c0619*******/system/0/Dc/Battery/Voltage
      transformationPattern: JSONPATH:$.value
  - id: pv_battery_power
    channelTypeUID: mqtt:number
    label: Battery Power
    description: null
    configuration:
      formatBeforePublish: "%.4f"
      stateTopic: N/c0619*******/system/0/Dc/Battery/Power
      transformationPattern: JSONPATH:$.value      
  - id: pv_power_pv
    channelTypeUID: mqtt:number
    label: Solar Power
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Dc/Pv/Power
      transformationPattern: JSONPATH:$.value
  - id: pv_power_consumptionL1
    channelTypeUID: mqtt:number
    label: Consumption L1
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Ac/Consumption/L1/Power
      transformationPattern: JSONPATH:$.value
  - id: pv_power_consumptionL2
    channelTypeUID: mqtt:number
    label: Consumption L2
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Ac/Consumption/L2/Power
      transformationPattern: JSONPATH:$.value
  - id: pv_power_consumptionL3
    channelTypeUID: mqtt:number
    label: Consumption L3
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Ac/Consumption/L3/Power
      transformationPattern: JSONPATH:$.value
  - id: grid_power_consumptionL1
    channelTypeUID: mqtt:number
    label: Grid L1
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Ac/Grid/L1/Power
      transformationPattern: JSONPATH:$.value
  - id: grid_power_consumptionL2
    channelTypeUID: mqtt:number
    label: Grid L2
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Ac/Grid/L2/Power
      transformationPattern: JSONPATH:$.value
  - id: grid_power_consumptionL3
    channelTypeUID: mqtt:number
    label: Grid L3
    description: null
    configuration:
      stateTopic: N/c0619*******/system/0/Ac/Grid/L3/Power
      transformationPattern: JSONPATH:$.value
  - id: pv0_power
    channelTypeUID: mqtt:number
    label: PV0 Power
    description: null
    configuration:
      stateTopic: N/c0619*******/solarcharger/0/Yield/Power
      transformationPattern: JSONPATH:$.value
  - id: pv1_power
    channelTypeUID: mqtt:number
    label: PV1 Power
    description: null
    configuration:
      stateTopic: N/c0619*******/solarcharger/1/Yield/Power
      transformationPattern: JSONPATH:$.value            
      
After Channels, go to Settings -> Items -> Add Items from Textual Definition and paste below rows:

Group Victron         "Victron"                       <energy>            ["Inverter"]
Number pv_battery_soc         "Battery SoC"           <energy>  (Victron) ["Energy"] { channel="mqtt:topic:pihome:vitronthings:pv_battery_soc" }
Number pv_battery_temp         "Battery Temperature"  <energy>  (Victron) ["Temperature"] { channel="mqtt:topic:pihome:vitronthings:pv_battery_temp" }
Number pv_battery_state        "Battery State"        <energy>  (Victron) ["Status"] { channel="mqtt:topic:pihome:vitronthings:pv_battery_state" }
Number pv_battery_voltage      "Battery Voltage"      <energy>  (Victron) ["Voltage"] { channel="mqtt:topic:pihome:vitronthings:pv_battery_voltage" }
Number pv_battery_power        "Battery Power"        <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv_battery_power" }
Number pv_power_pv             "Solar Power"          <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv_power_pv" }
Number pv_power_consumptionL1  "Consumption L1"       <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv_power_consumptionL1" }
Number pv_power_consumptionL2  "Consumption L2"       <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv_power_consumptionL2" }
Number pv_power_consumptionL3  "Consumption L3"       <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv_power_consumptionL3" }
Number grid_power_consumptionL1 "Grid L1"             <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:grid_power_consumptionL1" }
Number grid_power_consumptionL2 "Grid L2"             <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:grid_power_consumptionL2" }
Number grid_power_consumptionL3 "Grid L3"             <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:grid_power_consumptionL3" }
Number pv0_power              "PV0 Power"             <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv0_power" }
Number pv1_power              "PV1 Power"             <energy>  (Victron) ["Power"] { channel="mqtt:topic:pihome:vitronthings:pv1_power" }

 

Insert it, and you're done! In OpenHAB, you now have real-time data from Victron. You can create various rules and also access the history and graphs of these values in OpenHAB. It's up to you how you want to display this in your dashboard and what rules you want to create. We welcome any rule suggestions in the comments.

 

You can find a complete list of the values that can be read in the download link here:

Plain text icon victronmqttvariables.txt

 

 Tip: For all items, you can add Add metadata -> State description, and in the Pattern field, you can change the formatting. For example, a value like %.1f W in the Pattern field means rounding to one decimal place and the unit is Watts.

Rate the article:

No votes yet

Support Us:

Add comment:

Add comment

Newest articles in blog

Tailscale - remote access without public IP
Tailscale - remote access without public IPRating: 
90%

The Tailscale service solves access between individual devices if you don't have a public IP address. It's free for one user with support for up to 100 devices. We'll show you how to install Tailscale on a Raspberry Pi that you'll have at home and on a client (Android, iPhone) from which you'll want to access the home Raspberry Pi. Our example will be remote access to OpenHAB running on a Raspberry Pi. However, the same setup applies to many other applications - home NAS, PiHole, Home Assistant, Domoticz, NextCloud, and others.

Shelly OpenHAB MQTT
Shelly vs OpenHABRating: 
90%

The Shelly brand is known for its products that primarily communicate over WiFi, including smart plugs, relay switches, blinds control relays, and many other devices. One of the advantages for deployment is the ability to both read and control these devices using the universal MQTT protocol. Across existing add-ons for both OpenHAB and Home Assistant, we will demonstrate how to use Shelly devices without installing any additional extensions.

Victron & OpenHAB
Victron vs Smart HomeRating: 
0%

In this post, we will show you how to retrieve information from a photovoltaic power plant by Victron. We will connect to the Cerbo unit via MQTT. Based on these values, we can control various appliances (heating, boiler, etc.) and prevent the battery from being drained when they don't need to be.

Smart Home GoodWe inverter
Smart Home vs GoodWeRating: 
50%

In the post, we will demonstrate step by step how to communicate directly with the GoodWe inverter in a smart home setup and obtain real-time information (unlike the SEMS portal). This information is essential if we want to react to current parameters in a smart home, such as activating additional cooling or controlling a socket with a various load.

Voice control smart home
Voice control of the houseRating: 
60%

In this article, we will connect the Amazon Echo Dot voice assistant with open source home automation. We won't be using OpenHAB Cloud, so everything runs locally. In this case, a few additional settings are necessary, but the result is worth it!

MikroTik - Winbox, DHCP, Ranges
Basics - Winbox, DHCPRating: 
68.8%

In this series, we will look at the step-by-step setup of MikroTik devices for home users or a small business (up to 25 people). In the first article, we will focus on the initial setup - we will download Winbox and set up DHCP for the primary network and guest network. Similarly, we will also adjust the WiFi settings.

Alarm Smart Home PIR
Alarm from existing PIR sensors in a smart home.Rating: 
0%

In a your smart home, PIR sensors may not only be used to switch lights on and off based on motion, it is possible to utilize these sensors to detect the presence of motion in a particular room. This information can be used to create a relatively reliable uncertified home security system. In this guide, you will find the logic for how this can work in the OpenHAB software in our model smart home.

NFC Tag Example in Smart Home
NFC tags in smart homeRating: 
80%

NFC (Near Field Communication) tags are small plastic or paper stickers that can be used to automate various functions in the smart home. In this article, we will show you examples of use and a guide on how to write an action on an NFC tag using a mobile phone.

WireGuard iOS
WireGuard on iOS devicesRating: 
88%

In this article, you will find a detailed guide on how to connect to WireGuard VPN from iOS.

WireGuard on Android device
WireGuard on Android devicesRating: 
80%

In this article, you will find a detailed guide on how to connect to WireGuard VPN from Android.