homebridge-mqttthing
homebridge-mqttthing copied to clipboard
mqttthing and Victron Venus OS support
Just a general wish for device support for the Victron Venus OS. I have it up and running, with the usual caveats of having to use temp and humidity for voltage and state of charge etc. Would be very useful and possibly for many people. FWIW.
I used this to gets started, it is for openhab, but is pretty relevant as a starting point to the mqttthing plugin: https://community.openhab.org/t/mqtt-1-x-2-x-interface-to-victron-ccgx/43888 Some info on the open source victron protocols if someone wants to have a look: https://www.victronenergy.com/live/open_source:start Thanks again for a great plugin!
It would also be really great if a specific keep alive function string/command could be set from within the mqttthing plugin. The Victron gear wants a keep alive every 60 secs. Other than that, this works great.. many thanks.
You can send a keep-alive by using a codec. For example, place this file (keep-alive-codec.js) next to your config.json file:
// keep-alive-codec.js
module.exports = {
init: function( params ) {
let { config, publish } = params;
// publish keep-alive topic at regular interval
if( config.keepAliveTopic ) {
let keepAlivePeriod = config.keepAlivePeriod || 60;
let keepAliveMessage = config.keepAliveMessage || '';
setInterval( () => {
publish( config.keepAliveTopic, keepAliveMessage );
}, keepAlivePeriod * 1000 );
}
// no encode/decode in this codec
return {};
}
};
... then add this to your accessory configuration:
"codec": "keep-alive-codec.js",
"keepAliveTopic": "keep/alive",
"keepAlivePeriod": 30,
"keepAliveMessage": "Keep-alive!"
Many thanks, will try this right away! When you write "add this to your accessory configuration" what file do you mean that goes into? config.json? Thanks again!
Yes. I tested it with this:
{
"accessory": "mqttthing",
"type": "lightbulb-HSV",
"name": "Test espurna Light",
"url": "http://192.168.10.35:1883",
"topics": {
"getHSV": "test/hsvlight2/hsv",
"setHSV": "test/hsvlight2/hsv/set",
"getOn": "test/hsvlight2/on",
"setOn": "test/hsvlight2/on/set"
},
"logMqtt": true,
"integerValue": true,
"codec": "keep-alive-codec.js",
"keepAliveTopic": "keep/alive",
"keepAlivePeriod": 30,
"keepAliveMessage": "Keep-alive!"
}
This works great! Have had it running for a few hours so far with zero issues. It solves my issue 100% to automate some vital things based on a few parameters in the Venus OS. And it will be 100% neat when there are other icons and parameters in Home kit itself at some point. Many thanks again. Really appreciate this! Made my day!
Still working great here.. Related Q: Is it possible to add a client certificate file file via the mqtt options? If so, some code would be great if possible? Many thanks.
The only mention of certificates I can see at https://www.npmjs.com/package/mqtt#client is to disable rejection of self-signed server certificates. I'm not sure that MQTT supports client certificates.
Ok. Then it is probably above my skillset to figure out I'm afraid.. I'll definitely give it a shot on my setup if someone can provide an example for config.json to try out. The Victron Venus public MQTT server requires the use of a client certificate. The local connection to a Venus gx does not. So my local connection works great as is with mqttthing. FWIW.
Sorry, I take that back! TLS options are passed straight through to https://nodejs.org/api/tls.html#tls_tls_connect_options_callback.
Looking at https://github.com/mqttjs/MQTT.js/issues/1077 I'll need to add a way for you to specify filenames that mqttthing loads.
I see. Here is the .crt file that Victron uses if that helps for the specific case of the Venus OS: https://github.com/victronenergy/dbus-mqtt I'll definitely try it if you get to it. Many thanks.
The latest release (v1.1.19) now allows certificate files to be loaded for MQTT. See https://github.com/arachnetech/homebridge-mqttthing/blob/v1.1.19/docs/Configuration.md#mqtt-settings for details.
@houser42 could you post your config for this? I've tried to replicate what is detailed here but it seems I never get any actual values from MQTT.
Hello @baroldgene I have taken a different path and is using a different combo and config so I'm afraid I can't help with this anymore. If you are generally trying to get a Venus GX device working with MQTT and Node Red, I might be able to answer a q or two?
Ah gotcha. Sadly I'm just trying to get my Ruuvi temp sensors (connected to my Cerbo GX) to show in homekit. Seems a futile effort maybe.
That should be reasonably straight forward if you are using Venus OS Large and Node red. I do tons of that sort of thing, translating the IOT thingamajigs to HomeKit in Node red. Both for simple display and also switching. Never used the Ruuvi sensors, but if they are cumbersome, there are many cheap temp sensors (I tend to use mostly use €15 Shelly Wifi sensors but anything that has a decent NR package should work) that will allow you to get temps humidity and such into HK without paying a fortune. This might be useful to you also: https://community.victronenergy.com/questions/194264/control-mppt-relay-via-ruuvi-temperature-in-node-r.html