Page 1 of 1

node red itho wtw

Posted: Saturday 06 July 2024 19:06
by tiga
i am a total noob with node red and i am stuck.
i am browzing for an answer for a couple of days but can not succeed.

i have a mqtt connection with a ventilation unit and i want to extract for example the "bypass position" and make it a switch in domoticz.

the value is 1 for open, and 0 for closed.

this is what i get in the debug node in node red:

Code: Select all

6-7-2024 19:15:06node: debug wtw
itho/ithostatus : msg.payload : Object
object
Requested fanspeed (%): 30
Balance (%): 99
Supply fan (RPM): 1267
Supply fan actual (RPM): 1267
Exhaust fan (RPM): 1378
Exhaust fan actual (RPM): 1374
Supply temp (°C): 19.45
Exhaust temp (°C): 20.3
Status: 0
Room temp (°C): 20.3
Outdoor temp (°C): 19.45
Valve position: 0
Bypass position: 1
Summercounter: 300
Summerday (K_min): 1
Frost timer: 0
Boiler timer: 177
Frost block: 120
Current position: 720
VKKswitch: 0
GHEswitch: 0
Airfilter counter: 261
Global fault code: 0
Actual Mode: 2
Pir fan speed level: -1
Highest received CO2 value (Ppm): 32767
Highest received RH value (%RH): 239
Air Quality (%): 119.5
Remaining override timer (Sec): 0
Fallback speed timer (Sec): 0
Label out of bound error: 0
how can i filter out the bypass position and send it to a virtual switch in domoticz?

Edit Waltervl: moved to correct sub forum.

Re: node red itho wtw

Posted: Saturday 06 July 2024 19:33
by waltervl
Instead of node red you can also use the mqttmapper plugin that maps mqtt topics with domoticz devices.
See the following topic for more info https://www.domoticz.com/forum/viewtopic.php?t=39279

Re: node red itho wtw

Posted: Saturday 06 July 2024 22:00
by tiga
thanks for the tip!i am testing it right now but i am not sure what to fill out for the topic in this case.....

lets say i want the room temperature

it have to look something like this i think????::

Code: Select all

 "topic": "itho/ithostatus/"Room temp (°C)"",
this is not right becouse it is not working :D

Re: node red itho wtw

Posted: Saturday 06 July 2024 23:09
by waltervl
Better go to that mqttmapper topic and post your mqtt payloads and topic names there.

Re: node red itho wtw

Posted: Sunday 07 July 2024 18:52
by FireWizard
Hi @tiga,

I really wonder how mqttmapper should handle the communication with an Itho ventilation communication unit.
In my opinion that is not possible. So, since you have already a JSON object available in Node-RED, the easiest way to communicate with
Domoticz is to convert the payload to the right format and send it by MQTT to Domoticz.

I assume:

1. All data in the JSON object are numbers and not strings
2. you have a properly configured MQTT server, such as Mosquitto, running.
2. You have Domoticz configured to communicate with this MQTT server.

I created a simulation in Node-RED with the data, you provided.

Seem the picture below:

Screenshot_Itho1.png
Screenshot_Itho1.png (78.34 KiB) Viewed 6522 times

You asked:
i have a mqtt connection with a ventilation unit and i want to extract for example the "bypass position" and make it a switch in domoticz.

the value is 1 for open, and 0 for closed.
The 2 Inject nodes inject either 0 or 1 (1 equals "Open" and 0 equals "Closed"

Do the following:

1. Create a Dummy device in Domoticz Hardware
2. Create a virtual switch
3. Edit that switch and change it to "Contact"
4. Note its "idx" number.
5. Configure the MQTT out node, to the correct IP address and (if used) username/password.

You can simplle connect the "Function" node parallel to your "Debug" node.
See the picture above

The "Function"node contains the following:

Code: Select all

let idx = 105

if (msg.payload["Bypass position"] === 0) {
    msg.payload = { "command": "switchlight", "idx": idx, "switchcmd": "Off" };
}
else if (msg.payload["Bypass position"] === 1) {
    msg.payload = { "command": "switchlight", "idx": idx, "switchcmd": "On" };
}
return msg;
Replace in the first line the idx number (105) with the one you noted in step 4.

This should be the result:

Screenshot_Itho2.png
Screenshot_Itho2.png (40.35 KiB) Viewed 6522 times

And in Domoticz:

Screenshot_Itho3.png
Screenshot_Itho3.png (45.19 KiB) Viewed 6522 times
The complete test flow:

Code: Select all

[
    {
        "id": "3aee67607fadd318",
        "type": "tab",
        "label": "Itho Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "f13d15156641d964",
        "type": "inject",
        "z": "3aee67607fadd318",
        "name": "Inject Closed",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "itho/ithostatus",
        "payload": "{\"Requested fanspeed (%)\":30,\"Balance (%)\":99,\"Supply fan (RPM)\":1267,\"Supply fan actual (RPM)\":1267,\"Exhaust fan (RPM)\":1378,\"Exhaust fan actual (RPM)\":1374,\"Supply temp (°C)\":19.45,\"Exhaust temp (°C)\":20.3,\"Status\":0,\"Room temp (°C)\":20.3,\"Outdoor temp (°C)\":19.4,\"Valve position\":0,\"Bypass position\":0,\"Summercounter\":300,\"Summerday (K_min)\":1,\"Frost timer\":0,\"Boiler timer\":177,\"Frost block\":120,\"Current position\":720,\"VKKswitch\":0,\"GHEswitch\":0,\"Airfilter counter\":261,\"Global fault code\":0,\"Actual Mode\":2,\"Pir fan speed level\":-1,\"Highest received CO2 value (Ppm)\":32767,\"Highest received RH value (%RH)\":239,\"Air Quality (%)\":119.5,\"Remaining override timer (Sec)\":0,\"Fallback speed timer (Sec)\":0,\"Label out of bound error\":0}",
        "payloadType": "json",
        "x": 670,
        "y": 320,
        "wires": [
            [
                "80ce0b1edd4d5254",
                "b236a662b2be6443"
            ]
        ]
    },
    {
        "id": "80ce0b1edd4d5254",
        "type": "debug",
        "z": "3aee67607fadd318",
        "name": "debug wtw",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 870,
        "y": 320,
        "wires": []
    },
    {
        "id": "b236a662b2be6443",
        "type": "function",
        "z": "3aee67607fadd318",
        "name": "function 21",
        "func": "let idx = 105\n\nif (msg.payload[\"Bypass position\"] === 0) {\n    msg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Off\" };\n}\nelse if (msg.payload[\"Bypass position\"] === 1) {\n    msg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"On\" };\n}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 870,
        "y": 380,
        "wires": [
            [
                "aadca20b91373ed7",
                "b5bdbb0a529628d8"
            ]
        ]
    },
    {
        "id": "aadca20b91373ed7",
        "type": "debug",
        "z": "3aee67607fadd318",
        "name": "debug 233",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1070,
        "y": 440,
        "wires": []
    },
    {
        "id": "b5bdbb0a529628d8",
        "type": "mqtt out",
        "z": "3aee67607fadd318",
        "name": "To Domoticz",
        "topic": "domoticz/in",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "38b35487299a036d",
        "x": 1070,
        "y": 380,
        "wires": []
    },
    {
        "id": "eefcd94158e3c812",
        "type": "inject",
        "z": "3aee67607fadd318",
        "name": "Inject Open",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "itho/ithostatus",
        "payload": "{\"Requested fanspeed (%)\":30,\"Balance (%)\":99,\"Supply fan (RPM)\":1267,\"Supply fan actual (RPM)\":1267,\"Exhaust fan (RPM)\":1378,\"Exhaust fan actual (RPM)\":1374,\"Supply temp (°C)\":19.45,\"Exhaust temp (°C)\":20.3,\"Status\":0,\"Room temp (°C)\":20.3,\"Outdoor temp (°C)\":19.4,\"Valve position\":0,\"Bypass position\":1,\"Summercounter\":300,\"Summerday (K_min)\":1,\"Frost timer\":0,\"Boiler timer\":177,\"Frost block\":120,\"Current position\":720,\"VKKswitch\":0,\"GHEswitch\":0,\"Airfilter counter\":261,\"Global fault code\":0,\"Actual Mode\":2,\"Pir fan speed level\":-1,\"Highest received CO2 value (Ppm)\":32767,\"Highest received RH value (%RH)\":239,\"Air Quality (%)\":119.5,\"Remaining override timer (Sec)\":0,\"Fallback speed timer (Sec)\":0,\"Label out of bound error\":0}",
        "payloadType": "json",
        "x": 670,
        "y": 380,
        "wires": [
            [
                "80ce0b1edd4d5254",
                "b236a662b2be6443"
            ]
        ]
    },
    {
        "id": "38b35487299a036d",
        "type": "mqtt-broker",
        "name": "Raspberry Pi 1",
        "broker": "192.168.10.51",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

If you have any questions, let me know.

Best regards

Re: node red itho wtw

Posted: Monday 22 July 2024 13:12
by tiga
Thanks for the great help.

Mqtt mapper did the trick for me.

I will allso try node red to learn and use it thanks!