How to get this in domoticz

Moderator: leecollings

edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

How to get this in domoticz

Post by edwin1234 »

Hi ,
I have an air quality sensor from tuya and want to get it into domoticz
How should the function node look like?
The problem is it has a lot of sensors in one and the debug output shows only one ore two dps output and the next time a different one like for example first time:
dps: object
22: 368
t: 1739718165
Then second time
dps: object
18: 207
t: 1739718392
And so on
How to get all the data in a different device in domoticz
Like a temperature sensor
Co2 sensor
Humidity sensor
And so on.
How should the function node look like to get the information in domoticz.

Thanks
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Can someone pls help me in the right direction
Example only for dps 22?
So i can try to figure out the rest
Im not a programmer
Any help is welcome
Thanks
User avatar
habahabahaba
Posts: 233
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: How to get this in domoticz

Post by habahabahaba »

any screenshots, flow code...?
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

I wil post them this evening
Thx
User avatar
FireWizard
Posts: 1887
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: How to get this in domoticz

Post by FireWizard »

Hello @edwin1234,

Sorry Edwin, that I overlooked this post, but it is a somewhat unclear post.
After reading it again I have some questions, which you have to confirm
I have an air quality sensor from tuya and want to get it into domoticz
How do you receive the data from that Tuya device (MQTT, HTTP or otherwise)
How should the function node look like?
As you mention "function node", I think that you use Node-RED to read the sensor and want to send it to Domoticz.
How? MQTT? HTTP?
The problem is it has a lot of sensors in one and the debug output shows only one ore two dps output and the next time a different one like for example first time:
Google tells me that Tuya has these type of devices, which shows multiple environmental data.

The debug (again Node-RED) shows only one or two means probably that each value is sent in a separate message.
What do dps mean (data points)
dps: object
22: 368
t: 1739718165
I think that 22:386 is a key/value pair, but I have no idea what 22 means and what 386 means in this respect.
t: 1739718165 is the timestamp
18: 207
t: 1739718392
That is a different key/value pair, but what is it

How many of these key/value pairs exist?
And so on
So, others may guess? Questions like this, nobody can answer.
How to get all the data in a different device in domoticz
Like a temperature sensor
Co2 sensor
Humidity sensor
And so on.
It is not that difficult, as long as we know what it is
And as long as we don't know that, it is difficult to help you
How should the function node look like to get the information in domoticz.
If you can be clear, we can help you. Even the header (How to get this) of this topic is unclear.
It will not attract the attention of other forum users.

Regards
Last edited by FireWizard on Sunday 09 March 2025 13:31, edited 1 time in total.
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

This sensor is a multisensor and shows temperature,humidity,co2,voc
And i want to get the values in domoticz but dont know how.

Image

Code: Select all

 [
    {
        "id": "9c3398cde31dceef",
        "type": "tab",
        "label": "Flow 17",
        "disabled": false,
        "info": ""
    },
    {
        "id": "fa3b01e4852166e5",
        "type": "tuya-smart-device",
        "z": "9c3398cde31dceef",
        "deviceName": "LuchtKwaliteit",
        "disableAutoStart": false,
        "deviceId": "01064140308398878629",
        "deviceKey": "4eb01c7549f66719",
        "deviceIp": "",
        "retryTimeout": 1000,
        "findTimeout": 1000,
        "tuyaVersion": "3.1",
        "eventMode": "event-both",
        "x": 200,
        "y": 160,
        "wires": [
            [
                "3523dbf35fe4701a"
            ],
            []
        ]
    },
    {
        "id": "3523dbf35fe4701a",
        "type": "debug",
        "z": "9c3398cde31dceef",
        "name": "Luchtkwaliteit ",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 400,
        "y": 260,
        "wires": []
    },
    {
        "id": "39430bfdefae47bc",
        "type": "inject",
        "z": "9c3398cde31dceef",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 60,
        "y": 320,
        "wires": [
            [
                "fa3b01e4852166e5"
            ]
        ]
    }
]
This is the tuya sensor
Image

If you need more information let me know please.
Thanks
Attachments
FCFA9E75-44DE-45F0-AA71-AB1E0DF25D45.jpeg
FCFA9E75-44DE-45F0-AA71-AB1E0DF25D45.jpeg (95.44 KiB) Viewed 1330 times
C31B15BF-0E39-4420-AD5B-E73DB279AEAD.png
C31B15BF-0E39-4420-AD5B-E73DB279AEAD.png (88.14 KiB) Viewed 1333 times
User avatar
FireWizard
Posts: 1887
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: How to get this in domoticz

Post by FireWizard »

hello @edwin1234,

As you only sent some screenshot, I made a simulation as follows:

Tuya-Node-RED.png
Tuya-Node-RED.png (65.64 KiB) Viewed 1322 times
And below the flow:

Code: Select all

[
    {
        "id": "a36df463ae2177b1",
        "type": "tab",
        "label": "Test Tuya",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "60ada4c9e2935d7e",
        "type": "inject",
        "z": "a36df463ae2177b1",
        "name": "22",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{ \"data\": {\"dps\": {\"22\": 368, \"t\": 1739718165}}}",
        "payloadType": "json",
        "x": 730,
        "y": 360,
        "wires": [
            [
                "e98ffbd91e8e474e"
            ]
        ]
    },
    {
        "id": "88c897f6d4d2ae3e",
        "type": "inject",
        "z": "a36df463ae2177b1",
        "name": "18",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{ \"data\": {\"dps\": {\"18\": 207, \"t\": 1739718392}}}",
        "payloadType": "json",
        "x": 730,
        "y": 440,
        "wires": [
            [
                "e98ffbd91e8e474e"
            ]
        ]
    },
    {
        "id": "e98ffbd91e8e474e",
        "type": "switch",
        "z": "a36df463ae2177b1",
        "name": "",
        "property": "payload.data.dps",
        "propertyType": "msg",
        "rules": [
            {
                "t": "hask",
                "v": "22",
                "vt": "str"
            },
            {
                "t": "hask",
                "v": "18",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 890,
        "y": 400,
        "wires": [
            [
                "8d3608fdd71ba935",
                "20693e810e15f159"
            ],
            [
                "97e0bbfe6024e72a",
                "7bfa0993f3e68360"
            ]
        ]
    },
    {
        "id": "8d3608fdd71ba935",
        "type": "debug",
        "z": "a36df463ae2177b1",
        "name": "debug 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1040,
        "y": 320,
        "wires": []
    },
    {
        "id": "97e0bbfe6024e72a",
        "type": "debug",
        "z": "a36df463ae2177b1",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1040,
        "y": 480,
        "wires": []
    },
    {
        "id": "4225e5fa4b8ee092",
        "type": "debug",
        "z": "a36df463ae2177b1",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1260,
        "y": 400,
        "wires": []
    },
    {
        "id": "20693e810e15f159",
        "type": "function",
        "z": "a36df463ae2177b1",
        "name": "function 2",
        "func": "msg.payload = { \"command\": \"udevice\", \"idx\": 123, \"nvalue\": 0, \"svalue\": msg.payload.data.dps[\"22\"]}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1040,
        "y": 380,
        "wires": [
            [
                "4225e5fa4b8ee092"
            ]
        ]
    },
    {
        "id": "7bfa0993f3e68360",
        "type": "function",
        "z": "a36df463ae2177b1",
        "name": "function 3",
        "func": "msg.payload = { \"command\": \"udevice\", \"idx\": 456, \"nvalue\": 0, \"svalue\": msg.payload.data.dps[\"18\"]}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1040,
        "y": 420,
        "wires": [
            [
                "4225e5fa4b8ee092"
            ]
        ]
    }
]
Do the following.

1. For each sensor (with a number) add an extra output in the "Switch node

2. In the first line of the "Function" node insert the correct Domoticz IDX number

3. Replace the last Debug node with your own "MQTT Output" node.

Let me know, if this example helps.

Regards
Last edited by FireWizard on Tuesday 18 February 2025 22:20, edited 1 time in total.
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Thank u firewizard for your answer
Yes your example flow does help a lot
I think i can figure out the rest.

Thanks a lot
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Hi firewizzard
I changed the debug node to mqt out like you told me in your post and get this send by mqtt
{
"command": "udevice",
"idx": 2346,
"nvalue": 0,
"svalue": 358
}

Is gives me an error in the domoticz log Error: Mqtt: MQTT: Invalid data received!
Did i do something wrong in node red?

Thx
Greetings
Edwin
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: How to get this in domoticz

Post by jvdz »

The variable svalue (StringValue) need to be a string, so enclose it in double quotes:

Code: Select all

{
"idx": 2346,
"nvalue": 0,
"svalue": "358"
}

.. but when idx 2346 is an air quality sensor, then it requires the PPM value to be in the nvalue parameter:

Code: Select all

{
"idx": 2346,
"nvalue":358
}
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
FireWizard
Posts: 1887
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: How to get this in domoticz

Post by FireWizard »

Hello @edwin1234,

What @jvdz said, is correct and I'm sorry, that I was somewhat inaccurate in my example.

"nvalue" should always be a number, while "svalue" should always be a string.

123 is a number and "123" is a string.

You can easily correct this by putting toString() at the end of the "svalue", so that the contents of the "Function" node looks like:

Code: Select all

msg.payload = { "command": "udevice", "idx": 123, "nvalue": 0, "svalue": msg.payload.data.dps["22"].toString()}
return msg;
In the debug node, you will see the value in red and between " " (number you will see in blue, without " ")

Regards
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Ok
Thank you both
For explaining it to me
User avatar
FireWizard
Posts: 1887
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: How to get this in domoticz

Post by FireWizard »

Hello @edwin1234,

One thing I would like to mention as well.

@jvdz said also
but when idx 2346 is an air quality sensor, then it requires the PPM value to be in the nvalue parameter:
As I look to one of your pictures, I see that you indeed have "air quality" sensors, as I see:

"Formaldehyde detected" (0.02 ppm) and 'VOC (what ever that may be) detected" (0.1 ppm) and "CO2 detected" (368 ppm)
Probably you have more air-quality sensors with ppm values.

If you look to https://piandmore.wordpress.com/2019/02 ... -domoticz/ you will find:
Air quality

The air quality sensor will some value in ppm. You can only send whole numbers.

{"command":"udevice", "idx":1234, "nvalue":3}
and at https://wiki.domoticz.com/Domoticz_API/ ... ir_quality
Air quality

/json.htm?type=command&param=udevice&idx=IDX&nvalue=PPM

IDX = id of your device (This number can be found in the devices tab in the column "IDX")
PPM = CO2-concentration

Calculated status from PPM value:

airquality < 700 status text: "Excellent"

airquality < 900 status text: "Good"

airquality < 1100 status text:"Fair"

airquality < 1600 status text: "Mediocre"

airquality >= 1600 status text: "Bad"
If this is still true (the piandmore website is quite old), you can only put the CO2 value in a "air quality sensor".
For the others, you will need a "Custom sensor΅, as they are not whole numbers.

For the CO2 value in a "air quality sensor" you have to send:

Code: Select all

msg.payload = { "command": "udevice", "idx": 123, "nvalue": msg.payload.data.dps["22"]}
return msg;
For the "Custom sensors" the value should be in "svalue" as a String. (As shown in my previous post).

Regards
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Ok,
Thank u for your answer
I have indeed a co2 meter, and its working now with your and firewizards help
Greetings
Edwin
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

I have added the humidity also from the same device. “Luchtkwaliteit” Its working but it shows 550 instead of 55% does some one knows how to correct get the decimal ?
Is that done in node red or domoticz ?

Thanks
Edwin
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: How to get this in domoticz

Post by jvdz »

edwin1234 wrote: Friday 07 March 2025 6:00 “Luchtkwaliteit” Its working but it shows 550 instead of 55%
I don't understand the question, as "Air quality" has a value in PPM, and 550 sounds like an excellent air quality!
Humidity, normally part/combined with a Temperature sensor, should be another Sensor type that you need to update.
Please show use the Device info of the Humidity Sensor device and how you update that.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
FireWizard
Posts: 1887
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: How to get this in domoticz

Post by FireWizard »

Hi @edwin1234,

I think, you receive the Humidity from the same sensor, that you called "Luchtkwaliteit". Obviously the Humidity sensor gives you an accuracy of 0.1 %. So 550 means 55.0%.
So you have to divide your value by 10. That is done in Node-RED.

However you can only send whole numbers and no decimals.
They are chopped of in Domoticz or you use the function toFixed() in Node-RED. And the Humidity sensor in Domoticz requires also an environment level, as second parameter.
This can be calculated in Node-RED as well.

What type of sensor, do you intend to use?

Regards
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Yes firewizard its the same sensor
I choosed a dummy Humidity sensor for the humidity in domoticz

Image

You see its working
Attachments
2B2C0538-CDE6-4709-B752-F34E262672BC.jpeg
2B2C0538-CDE6-4709-B752-F34E262672BC.jpeg (44.71 KiB) Viewed 973 times
User avatar
FireWizard
Posts: 1887
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: How to get this in domoticz

Post by FireWizard »

Hello edwin1234,

You should send the following from Node-RED to Domoticz:

Code: Select all

{"command":"udevice", "idx":1234, "svalue":"lv", "nvalue":hu}
,

where the nvalue is the humidity and the svalue is the level
The nvalue should be without decimals.

So send the following:

Code: Select all

msg.payload = { "command": "udevice", "idx": 1234, "nvalue": parseInt(msg.payload.humidity / 10), "svalue": "0"};
return msg;
where I assume that the msg.payload.humidity is the numeric value of the humidity, e.g. 451.

Try this

Regards
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to get this in domoticz

Post by edwin1234 »

Hi firewizard,
It
Works perfectly
Thanks for the answer
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest