Interfacing to Domoticz using MQTT



  • Glad to hear MQTT is available now, currently have the API integrated with Node-Red- thanks to Josh's docs and examples.

    If any of you are on Octopus Agile you might find this Node-Red thread interesting, it took a lot of help and learning but managed to crack automatically choosing the cheapest slots to charge, turn on electric heating, etc.

    This bit just uses the Octopus API- I have a separate bit to collect useage.

    A couple of us have evolved this a bit and now have data going to InfluxdB with Grafana displays.

  • Hi sidepipe,

    Many thanks for sharing this post and node-red setup. I am also a Domoticz user and have just received my Glowstick (although at the moment it doesn't seem to have been enabled on the Hildebrand side to connect to my smart meter).

    I'm planning to set up something similar to what you describe for your air source heat pump system. Would you mind sharing your domoticz script(s) as well so that I could take a look at how you've achieve this based on the average readings over the five minute period?


  • Would you mind sharing your domoticz script(s) as well so that I could take a look at how you've achieve this based on the average readings over the five minute period?

    Ok, there are a few dzvents scripts I use for this - I've put them here:

    Don't expect them to be great - it was all just a quick hack if I'm honest. Hopefully you'll make sense of it.

  • Thanks! I'll try to work it out. I haven't really scripted before in Domoticz so this will be a learning curve!

  • Hello,

    I've been using a Glow Stick for a few months now but only just got round to configuring MQTT on my raspberry pi to grab data.

    I've followed the instructions in post #1 and data output can be seen on the Node-Red debug screen:

    11/10/2020, 20:25:35 node: 873abf91.f3419

    SMART/HILD/************ : msg.payload : Object

    { command: "udevice", idx: 88, nvalue: 0, svalue: "511;13700450" }

    Domoticz is showing as connected but the data is not showing in the virtual sensor display.

    Is there an api command required to push the data into Domonicz?

  • ***************** FIXED *****************

    In the Domoticz Hardware setup screen for 'MQTT Client Gateway with LAN interface' I'd configured the Remote Address field with the remote server info ( instead of localhost.

  • Is there a Hildebarand MQTT node for NodeRED?

  • Just use a standard MQTT in node and configure it with the server url and your username, password and topic.

  • Is this still working for people? I have set it up in node red but it just constantly shows connecting.

  • mqtt is certainly still working

    node red I cannot comment on

    try a command line client to check you have the correct server settings, credentials and topic

  • I've been trying to get sidepipe's NodeRED flow to work but the Hildebrand SMQTT node just hangs showing "connecting"

    I've got Server = port = 8883

    username / password = same as I use to log into the Bright app.

    Any suggestions?

  • If things are still as they were when I set mine up last year you have to get MQTT set up by support, and you'll get a different username and password. That was over a year ago now though so may have changed.

  • "Any suggestions?"

    What topic are you subscribing to?

  • Morning all,

    I've just got this working. I also had the connecting issue, I rebuilt the flow from the script and it then started working.

    I do have two issues though, the electricity usage is out by a factor of 10, so 1Kw is showing as 10000 watts - how can i adjust this?

    Also the gas usage is in m3 rather than Kw, has anyone got any thoughts on how to swap that?


  • @billytkid

    To convert cubic metres to kilowatts you need to know the calorific value of the supplied gas (which can vary).

    • Multiply by the volume correction factor (1.02264).
    • Multiply by calorific value (~40.0).
    • Divide by kWh conversion factor (3.6).

    The calorific value can change and will be printed on your supplier's bill.

    For example from my last Octopus bill (for Feb 13th until Mar 13th) they included

    Your energy usage is calculated from your gas consumption using a standard industry formula: Units Consumed (Cubic Metres) × Volume Correction (for temperature & pressure) × Calorific Value (energy in each m3 of gas) ÷ 3.6 (convert from joules) ≈ Usage (in kWh)

    For you: 103.5 × 1.02264 × 39.2† ÷ 3.6 = 1152.8

  • Actually, the kWh value for historical consumption ( today, this week and this month ) is normally also available from the smart meter. These are at nodes under 0702->0C ( "alternative historical consumption" ) at 01, 30 and 40 respectively, so they can be used if you wish. I use them to work out the calorific value rather than using them directly, though note that on my smart meter at least the values can go really screwy around midnight at the end/start of a month.

  • Thank you all, this is great.

    All is working like a charm!


  • hi, honestly i dont understand any of this!

    All i want to do is get my usage into domoticz and then into grafana

    i dont really want to pull the info from the web so can i get my display to send it to a broker (installed mosquitto not suure if its set up correctly)

    like i say i have no idea what im really doing with this automation stuff


  • edited November 2022

    My CAD arrived and I got the MQTT to send the message, but I sadly realized it's in it's own format. Because I didn't want to install yet another thing on my system - and because one node based monster in form of zigbee2mqtt is enoug for me - I decided to go with a quick and dirty solution.

    I created 3 virtual devices: "Electric (Instant+Counter)", "Counter", "Counter". Out of the two counters I set one for gas and one for energy to add the gas kwh from the MQTT.

    I created a standalone python script to listen for MQTT messages and forward them to Domoticz via the JSON API, and systemd unit to make the python script run as a daemon. It needs `paho-mqtt` and requests modules to work.

    There's the python code and the system unit file:

    I consider this a temporary solution until I figure out how to convert the messages to a homeassistant friendly format - zigbee2mqtt already does that - so Domoticz will pick it up with the autodiscovery.

  • It did help a bit; I made a small Python script that only needs to be ran once and it kicks of the auto-discovery both in Domoticz and in Home Assistant.


    It can be done manually or with other clients, after that the devices will show up as Custom Sensors in Domoticz and under the same device in Home Assistant. I removed the *1000 bits because Domoticz doesn't seem to support it, hence the Custom Sensors.

  • In the end, I decided to do both, but only because I'm running Domoticz and Home Assistant parallel (still trying to decide whether I want to move from Domoticz or not).

    The MQTT to MQTT translation works fine for Home Assistant, the python daemon works better for Domoticz, because the auto discovery in Domoticz will stick all sensors as Custom Sensor instead of Electric and Counters.

  • @petermolnar

    Hi, thank you for sharing your code, it's been very useful.

    A couple of comments: -

    I think there may be a typo at line #52, I suspect you mean "energy" here, not "usage"?

    At line #34 I found I needed to use a multiplier of 100 rather than 1000. I guess my gas meter just reports volume differently from yours.

    Thanks again!

Sign In or Register to comment.