Mqtt value to domoticz

I've been searching for a while too, but I can't figure it out.

I've checked the websites, but they have predefined values. I want to send a value from MQTT Node-RED using an HTTP rule or another way to Domoticz. The value comes from Node-RED.

I want this value to a counter in Domoticz.

afbeelding

Sorry, that doesn't make sense. If you want to send a value to MQTT you just use an MQTT Out node.

I want to send a value to a counter in Domoticz.

You would use the http request node.
Not knowing the Domoticz webhook url it is hard to say much more.
This is a simple example, you would have to add the correct url for your Domoticz.
You may find better help to find the correct the url on the Domoticz forum.

[{"id":"e97e8fc8c8bebf01","type":"http request","z":"d1395164b4eec73e","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.23?value={{payload}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":770,"y":7780,"wires":[["41f71d0cd684effc"]]},{"id":"ffb65c2b7dd50673","type":"inject","z":"d1395164b4eec73e","name":"mqtt in","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"12345","payloadType":"num","x":610,"y":7780,"wires":[["e97e8fc8c8bebf01"]]},{"id":"41f71d0cd684effc","type":"debug","z":"d1395164b4eec73e","name":"debug 2487","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":7780,"wires":[]}]

This suggests that you can use MQTT with Domoticz. MQTT - Domoticz

Hello @nodouser,

What should that number value in your node represent?

It is just a number.
Should it be displayed in a Domoticz "Text" widget?
Or something else?
You said a counter. What is it? Is it a Custom sensor?

Regards

I have a water meter that sends consumption data to Node-RED. Using Node-RED, I've created an incremental counter so that I can track how much water has passed through the water softener. This helps me know when salt needs to be filled.

Once I refill the salt, I reset the counter so that I always know there's enough salt in the water softener. Everything works within Node-RED, but I want to see the water consumption in Domoticz. The value is visible in the Debug. So, I need to add a line in the function node that forwards the value to domoticz, or perhaps there's a better way?
So far it works.

I do use often a function node for sending a state of a switch to domoticz, but sending a value is new for me.

In domoticz i think this is the best way,

afbeelding

Hopefully, it's clear now.

Hello @nodouser,

Yes, it is almost clear. I do understand the objective of your flow.

What is important to know, is what does the number value represent?
For now, I assume, that it is a number in Liters (L).

The "RFX Counter" in Domoticz could be seen as a sensor.
Another Domoticz user has created a nice list of the various sensors possible in Domoticz.

See: MQTT out for Domoticz – PI and more
Unfortunately the information, written for a water counter is wrong. You should use the information at: Domoticz API/JSON URL's - Domoticz

To send the data to Domoticz you can use a "Function" node in front of the MQTT out node to Domoticz, with the following content:

const idx = 12345 //  Replace 12345 with the Domoticz IDX number of your sensor.

msg.payload = { "command": "udevice", "idx": idx, "nvalue": 0, "svalue": msg.payload.toString() };

return msg;

"command": "udevice" is default, but I included it for completeness.
Also "nvalue": 0, you may omit, as it is not needed in this case.
Do not forget to replace the number 12345 in the first line with your idx number.

In order to configure the right dividers for the water counter, see the discussion on the Domoticz forum (this is about the HomeWizard water device, but is applicable in your case, as well):
https://www.domoticz.com/forum/viewtopic.php?t=39178&hilit=water

Regards

1 Like

Yes, that was the solution, and indeed liters.
When 30,000 liters have passed through the water softener, I need to refill the salt.
It's a bit of a learning curve with Node-RED, but it's great once you have it working.

Thanks for the support!

Keep the following in mind:

  1. The Counter in the upper right corner displays in liters and is a daily counter (CounterToday) and will be reset to zero at midnight.
  2. The Counter in the middle of the widget displays in m3 (cubic_meter) and will not be reset.
  3. In order to reset that counter you have to send the negative counter value.

I do not know how you reset the counter, but I would implement a virtual switch and configure it as a "On" button. and send a status update by MQTT to Node RED.

In Node-RED, when I receive the reset command, I would request status information from the widget (node) and send that negative value to MQTT.

See an example below. Replace the IDX (rid) and the IP address:

[
    {
        "id": "6685db4105e29da0",
        "type": "http request",
        "z": "65711f41c50e0302",
        "name": "",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "http://192.168.10.50:8080/json.htm?type=command&param=getdevices&rid=532",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 410,
        "y": 220,
        "wires": [
            [
                "b3edbc0b5e951831",
                "39c685e36ccae3c6"
            ]
        ]
    },
    {
        "id": "4b08b480637677b1",
        "type": "inject",
        "z": "65711f41c50e0302",
        "name": "Reset Counter",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 220,
        "wires": [
            [
                "6685db4105e29da0"
            ]
        ]
    },
    {
        "id": "b3edbc0b5e951831",
        "type": "debug",
        "z": "65711f41c50e0302",
        "name": "debug 231",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 610,
        "y": 220,
        "wires": []
    },
    {
        "id": "39c685e36ccae3c6",
        "type": "function",
        "z": "65711f41c50e0302",
        "name": "function 20",
        "func": "msg.payload = { \"command\": \"udevice\", \"idx\": msg.payload.result[0].idx, \"nvalue\": 0, \"svalue\": (-(parseFloat(msg.payload.result[0].Counter))).toString() };\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 280,
        "wires": [
            [
                "8b5327b71eb073bb"
            ]
        ]
    },
    {
        "id": "8b5327b71eb073bb",
        "type": "debug",
        "z": "65711f41c50e0302",
        "name": "debug 232",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 810,
        "y": 280,
        "wires": []
    }
]

Regards

Thanks!
I do have a rest button, it sets the value to 30.000 liter, when refill of the salt is done. The counter will decrement.

Maybe better not to use a meter that gets a reset during the night. I will test it for a few days, lets see how it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.