Connecting ebusd and emoncms via MQTT

I’ve just found time to set up my eBUS Adapter and ebusd, meaning I am now able to passively read or actively fetch values from my Vaillant heat pump. When values are updated on the bus I get a message on a topic like /ebusd/hmu/Status01 with some nice JSON contents about the current flow temperatures and pump status:

{
  "0": {
    "name": "temp1",
    "value": 38.5
  },
  "1": {
    "name": "temp1",
    "value": 35
  },
  "2": {
    "name": "temp2",
    "value": null
  },
  "3": {
    "name": "temp1",
    "value": null
  },
  "4": {
    "name": "temp1",
    "value": null
  },
  "5": {
    "name": "pumpstate",
    "value": "on"
  }
}

A lot of these “just show up”, because it seems like the Vaillant controller regularly polls for these values so ebusd sees them going past. Others I can trigger a fetch by publishing a message like ebusd/hmu/CurrentYieldPower/get, or set up polling by publishing to that topic with a message body like ?3.

{
  "0": {
    "name": "",
    "value": 5.8
  }
}

Note as @TrystanLea mentioned on Twitter the JSON structure is a little odd - it’s possible to get these as strings with ; delimiters for the multiple value fields. That might be easier to handle (from the CLI tool but the same values available via MQTT:

hmu CurrentCompressorUtil = 114
hmu CurrentConsumedPower = 1.9
hmu CurrentYieldPower = 5.8
hmu State = 0;757;129;8
700 Hc1PumpStatus = 1
hmu Status01 = 35.0;35.5;-;-;-;off

I’ve got EmonCMS running under Docker with https://github.com/emoncms/emoncms-docker/tree/v2 (although emonhub is temporarily disabled as I’ve not moved my RFM69Pi over so the initialisation fails). I understand that EmonCMS monitors the emon/ topic, but I’m not sure the best way to proceed from here.

So a few questions, with apologies as I’m a complete MQTT novice:

  • Should I simply tell ebusd to use emon/ebusd as its topic base? Or can I tell emon (or emonhub) to read some specific additional topics?
  • Can I make something in emoncms publish the “get” messages when it wants to update a value to read, or should I set up the polling in ebusd?
  • If the latter, is there something that can publish those polling messages or should I do that via the CPI and add a script to switch those on to my ebusd container? (look who learnt how to write a Dockerfile over Christmas! :laughing:)

Thanks!

Who needs sleep?! I’ve made some progress just moving the ebusd topic to emon/ebusd and have a small patch to unbox JSON values of the form { name: blarg, value: blarg } which I can submit later after a little more testing. :slight_smile:

1 Like

Great to hear @ramcq sounds like you have got this!?

Maybe?! https://github.com/emoncms/emoncms/pull/1779 looks promising:

I have some problems with string values - it seems like emoncms is just discarding them - is that expected? There are some which are obviously booleans (on / off / true / false / yes / no) which could be mapped to 1 or 0 with a generic function. Does that make sense to consider adding lower down in the MQTT service before it submits the values, or is there somewhere else that’s worth considering (on the way “in” to emoncms)?

However, some of the fields reported by ebusd are enums (see https://github.com/john30/ebusd-configuration/blob/master/ebusd-2.1.x/en/vaillant/_templates.csv#L86 for example) - is there somewhere in the pipeline I’d be able to configure a mapping for those I cared about?

I use node-red as the data manipulator between ebusd and emon using MQTT.
Node-red has timers which poll for certain data E.g. yield and help trigger the calculation of CoP

Yes.

Yes NR is often the best tool.

Ideally the JSON will be structured such that {"name": value, "name2": value2}. You can include a "time":timestamp_in_seconds as part of the JSON and this will be used for the Feed. Means any drift can be eliminated if you call / poll for the data regularly.

If you use NR then when you send the data as MQTT it automatically translates a Javascript Object into a JSON string. If you want to map booleans to 1/0 then do it there as well.