question

Dominik Immler avatar image
Dominik Immler asked

MQTT: Cerbo GX sendet nur die Seriennummer

Hallo allerseits.


Ich weiß dass dises Thema bereits mehrfach aufgekommen ist, leider konnte mir kein bisheriger Thread weiterhelfen.


Ich bekomme keine MQTT Topics vom Cerbo geliefert, bis auf die Seriennummer.

Um fehlerhafte Konfiguration vom RPi auszuschließen, möchte ich erst mal über den MQTT Explorer ordentliche Funktion vom Cerbo erkennen können.

Habe nun mehrfach davon gehört dass der Cerbo irgendwann nach einer gewissen Zeit aufhört die Topics zu Posten, wenn kein Keepalive Script das verhindert.

Ich gehe mal davon aus dass beim Start des Cerbo schon alle Topics die der Cerbo zur Verfügung hat, auch per MQTT ausgestraht werden sollten und diese über den MQTT Explorer ersichtlich sein müssten.

Genau dies geschieht bei mir nicht.

Ab neustart des Cerbo GX, sehe ich über den MQTT Explorer nur die Seriennummer.

Habe auf dem Cerbo GX die Firmware v2.87 am laufen. Gibt es da eventuell einen bekannten Bug?


Vielen Dank im Voraus!

SG

Dominik

bildschirmfoto-2022-08-27-um-125952.png

MQTT
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

7 Answers
taylortops avatar image
taylortops answered ·

Try like this:

In MQTT Explorer, Publish:

"R/<Your_VRM_Portal_ID>/keepalive" with no payload data. --note the leading "R"

Or in Javascript:

const keepalive_first = setImmediate(timer_handler);
const keepalive_timer = setInterval(timer_handler, 55000);
function timer_handler(){
                  
  client.publish("R/"+PORTAL_ID+"/keepalive", "", (err) =>{
                  
    if(err) console.log("pub_error->",err);
  })
}
5 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dominik Immler avatar image Dominik Immler commented ·
Hey taylortops, thanks for your two cents.


I`ll try that.

This just looks a lot like the script i added to the RPi, but i didn`t test it with the MQTT Explorer.

I`ll let you know.


Thanks


0 Likes 0 ·
taylortops avatar image taylortops commented ·
^^ Note my "client" is already logged in with username and password.
0 Likes 0 ·
Dominik Immler avatar image Dominik Immler commented ·
So would you recommend doing the "keepalive" by the Javascript-script?

As allready mentioned, i have a script on my RPi in place, which should just do this job, but doesn`t work.

How is this done with the Javascript. Creating a flow in node Red, which publishes this script via MQTT-out directly to the Cerbo-IP or rather the Mosquitto-Broker IP?


Thats what still bothers me. For what i understand the mosquitto Broker should be the distributor of all messages between the different clients.

In this/my case the clients should be the Cerbo, as well as Node-Red, right?

So how`s it possible to send the keepalive via MQTT Explorer directly to the Cerbos IP, instead to the mosquitto IP which should/could forward it to the Cerbo...

Thanks


0 Likes 0 ·
Dominik Immler avatar image Dominik Immler commented ·

Tried to implement the JS-Script into Node Red, but still have some problems with it.

This is the Flow for the keepalive:

bildschirmfoto-2022-08-30-um-210842.png

And this is the Script inside the function "CerboMQTT keepalive (JS)":

bildschirmfoto-2022-08-30-um-210912.png

As you can see the "client" is marked with the red line, so it cannot be compiled. Am i missing a plugin for this function?


Am i on the right Path?

Thanks.

0 Likes 0 ·
taylortops avatar image taylortops Dominik Immler commented ·

Oh I see. I don't know NodeRed that well but I'm fairly certain the you can set up timers in NodeRed and have this send a MQTT packet using it's own MQTT library. You shouldn't need to custom code the way I have.

Check out: https://community.victronenergy.com/questions/153664/node-red-daten-aus-cerbo-via-mqtt.html

I'm doing a pure javascript implementation not node-red but I'd be happy to share my code. I'm using this library: https://github.com/mqttjs/MQTT.js

Just so you have the full picture: all of your Victron devices send their data to the local Mosquitto broker on the Cerbo. The Cerbo uses a MQTT bridge to sync with the Mosquitto broker instance (VRM) in the cloud. Thus, you can talk to either broker and it functions as one.

Also see:

https://github.com/victronenergy/node-red-contrib-victron

http://www.steves-internet-guide.com/mqtt-keep-alive-by-example/

0 Likes 0 ·
holger Bleckwehl avatar image
holger Bleckwehl answered ·

So weit ich es weiss, muss man die Adressen angeben, von denen man Daten haben will.. der Cerbo ist ja ein Server und der schickt nur, was man ihm sagt.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dominik Immler avatar image
Dominik Immler answered ·

Hallo Holger und vielen Dank für deine Antwort.

Habe mir Jens (Meine Energiewende) sein Video angesehen und demnach alles eingerichtet.

Es ist sicherlich noch irgend ein Fehler drinnen, nur finde ich diesen bis Dato noch nicht.

Ich habe heute das Script nochmal geprüft mit dem der Jens das Publizieren der Topics gewährleistet und dementsprechend alles eingerichtet.

Heute bin ich draufgekommen, dass mir noch der Service "screen" fehlt, welchen ich nun nachinstalliert habe. Dennoch kein Erfolg.


Irgendwie mus ich ja mal den Cerbo dazu bewegen dass er mir meldet welche Topics er mir liefern kann...


SG

Dominik

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

johanndo avatar image
johanndo answered ·

Das ist der Mosquito Broker service und nicht die Seriennummer vom Cerbo. Du empfängst noch gar keine Victron Daten. Vielleicht musst du erst mal MQTT am VenusOS freigeben / einschalten.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dominik Immler avatar image
Dominik Immler answered ·

Also MQTT SSL und Plaintext im Cerbo sind an.

Das kann eigentlich nicht der Broker sein, denn die IP .111 ist die des Cerbo. Habe mich aber auch gewundert dass da unter $SYS ein Broker gelistet wird, noch dazu Mosquitto.

Heißt das also dass auf dem Cerbo bereits ein Broker, noch dazu Mosquitto läuft?

Der Mosquitto der auf dem RPi läuft ist jedoch die Version 2.0.11 (Mit der IP .112)

bildschirmfoto-2022-08-28-um-220115.png


SG


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dominik Immler avatar image
Dominik Immler answered ·

Hey taylortops.

I tried the command "R/<Your_VRM_Portal_ID>/keepalive" under MQTT Explorer, which worked fine. First time ever i could get my Cerbo to talk to me. Yesss :)

bildschirmfoto-2022-08-29-um-165626.png

This is great as i now know that the cerbo side of MQTT works as should.


So debugging on the RPi can proceed.

My first guess would be that this "...keepalive" in my RPi doesnt work properly.

Therefore i did the following on my RPi:

Edited the rc.local File with the additional Lines:

# Start Venus Poller
/usr/bin/screen -dmS poll-venus /root/poll-venus.sh


Under /root/ i created a File named "poll-venus.sh" with the Script:

while :; do mosquitto_pub -h 192.168.8.111 -m '' -t 'R/48e7da89c2bd/system/0/Serial'; sleep 30; done


You see any mistakes here?

Any way to check if this is working properly?


Thank you


5 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

taylortops avatar image taylortops commented ·
I think you should see the "keepalive" refreshing in MQTT Explorer.


What is your overall goal once you get the data?
0 Likes 0 ·
Dominik Immler avatar image Dominik Immler taylortops commented ·

If i trigger the Cerbo via the MQTT-Explorer, i can see the Topics coming in to the Node-Red`s - MQTT-In. So i think the reverse way should work the same.


I have an ESS installation with a 14kWh Battery and three Victron Multiplus Inverters running.

Especially in Summertime we have lot of exessive Energy, after allready recharging the Battery to 100%.

To raise the self-consumption of PV-Energy, i want to feed the Power into the Water-Boiler and therefore i wanna use the RPi with Node Red, to control the three Relays.

These three Relays will turn on, one after another for every 700W exessive Power.

Thats my plan so far.


All the best.

Dominik

0 Likes 0 ·
Meine_Energiewende avatar image Meine_Energiewende commented ·

Moin ! ist ja schön dass mein Script hier verwendet wird. Hast Du es auch ausführbar gemacht ? Was meldet Dir

mosquitto_pub -h 192.168.8.111 -m '' -t 'R/48e7da89c2bd/system/0/Serial'

zurück ? (da sollte garnichts kommen).

Was sagt

echo $? 

nach der Ausführung von oben aus ?

Viele Grüße

Jens von Meine_Energiewende


0 Likes 0 ·
Dominik Immler avatar image Dominik Immler Meine_Energiewende commented ·

Hallo Jens.


Erst mal vielen Dank für deine tollen Videos. Kann mir regelmäßig was von dir abschauen.

Mittlerweile bekomme ich die Topics von Cerbo, jedoch nicht über dein Script, sondern über einen Flow den ich in Node Red eingerichtet habe. Ich habe einen Inject-Knoten der einen leeren String als msg.payload weiterleitet an einen MQTT-Out Knoten, an dem folgendes Topic eingestellt ist "R/48e7da89c2bd/keepalive".

Das ganze wird direkt beim Start von Node Red, also nach dem booten vom RPi periodisch ausgeführt.

Von daher bin ich versorgt und kann die Steuerungsprogrammierung über Node Red nun starten.


Weil ich neugierig bin, hätte ich es trotzdem noch gerne mit deinem Script noch hinbekommen. Habe deinen oben erwähnten Befehle in der Console des RPi ausgeführt und folgendes erhalten:bildschirmfoto-2022-09-04-um-083654.png

Nach dem ich den mosuqitto_pub ausgeführt habe, hat der Cerbo direkt fröhlich die Nachrichten gesendet (ersichtlich im MQTT-Explorer).

Habe also den Eindruck, dass das script "poll-venus.sh" einfach nicht ausgeführt wird.

Was meinst du mit "hast du es ausführbar gemacht"? Also wie in deinem Video beschrieben habe ich in "rc.local" das screen auf das poll-venus.sh verwiesen...

Ich denke das sollte es dann gewesen sein?

Nun felt mir eben die Erfahrung über irgendwelche Log-Files oder so herauszufinden wieso das Script nicht geht x).


Vielleicht kann mir noch jemand diese Frage beantworten. Weshalb wird beim "Keepalive" vor der Seriennummer des Cerbo ein "R/" geschrieben und nicht das "N/"?


SG

Dominik


0 Likes 0 ·
gscholz avatar image gscholz Dominik Immler commented ·

> Was meinst du mit "hast du es ausführbar gemacht"?

chmod +x poll-venus.sh

0 Likes 0 ·
rudisoft avatar image
rudisoft answered ·

Ich dachte schon, die Cerbo Seriennummer würde ausreichen, um VRM Portal Zugriff zu bekommen und wollte warnen. Dem scheint aber nicht so zu sein. Gruß, Rüdiger

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources