SmartThings Airconditioner Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

SmartThings Airconditioner

Post by wkossen »

Hi,

I am trying to get my airconditioner working with domoticz. This has already been a long search, and i've made some progress, but i'm nowhere near finished. I need help getting it to work in node-red as a first step.

So here is what i have so far:
this plugin in nodered: https://flows.nodered.org/node/node-red ... martthings
i made the smartapp and have it working in the smartthings cloud app etc.

as a first step i want to fetch temperature and humidity from the airconditioner. so i set up two nodes to do that.
Screenshot 2020-12-09 at 12.34.35.png
Screenshot 2020-12-09 at 12.34.35.png (14.89 KiB) Viewed 961 times
they give some output:

Code: Select all

{"deviceId":"--long-ugly-string--","deviceType":"humidity","name":"Room air conditioner","value":37,"unit":"%"}
so it knows the room is dry as bones :/
i try to get that into domoticz with a simple mqtt node via a function node with this function:

Code: Select all

msg.payload = {"command":"udevice","idx":260,"nvalue":0,"svalue":msg.payload.toString()};
return msg;
that does not work. for the other node (temperature) i get something like this:

Code: Select all

{"command":"udevice","idx":259,"nvalue":0,"svalue":"{\"deviceId\":\"--long-ugly--string--\",\"deviceType\":\"temperature\",\"name\":\"Room air conditioner\",\"value\":22,\"unit\":\"C\"}"}
which i expected.
so i start trying split nodes, json nodes, trying to get msg.payload.value etc. i just don't know how to get that value extracted out of that string.
i'm no programmer or developer...
i actually don't really know what that string is. so i don't know how to extract one value out of it... any pointers?

the end goal is to also make flows to get it to work the other direction, to actually send commands to the airconditioner to heat or cool the room, or stop when i'm not there. but this first hurdle needs to be taken first.
User avatar
FireWizard
Posts: 1801
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SmartThings Airconditioner

Post by FireWizard »

Hi, @wkossen

Hi, your syntax for a "Humidity" sensor is wrong.

See also my post: viewtopic.php?f=28&t=34300

The correct syntax for the "Function" node and the "Humidity"sensor should be:

Code: Select all

msg.payload = {"command":"udevice", "idx":260, "nvalue":msg.payload.value, "svalue": "0"};
return msg;
Regarding the "Temperature" sensor.
What you have done, I do not know, but the contents of the complete output of the Temperature has been put in the svalue of the command to Domoticz.

I assume that you receive a similar command as for the Humidity sensor and that it looks like:

From the Humidity sensor you get:

Code: Select all

object
deviceId: "--long-ugly-string--"
deviceType: "humidity"
name: "Room air conditioner"
value: 37
unit: "%"
and I expect from the Temperature sensor this:

Code: Select all

object
deviceId: "--long-ugly--string--"
deviceType: "temperature"
name: "Room air conditioner"
value: 22
unit: "C"
The correct syntax for the "Function" node and the "Temperature" sensor should be:

Code: Select all

msg.payload = {"command":"udevice", "idx":259, "svalue":msg.payload.value.toString()};
return msg;
Regards
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: SmartThings Airconditioner

Post by wkossen »

well, that helped a lot. I can now see temp and hum in Domoticz. when should nvalue and svalue be used and why? i don't really get that, and i read the wiki. it does not really make a lot of sense... why is one toStrings() and the other not? in fact, why is there any toStrings() at all, as both values are numerical in nature.... maybe i'm trying logic and i shouldnt :/

but let's continue the litte project. I added a smartthings switch node and now also can see the status, is it on or off. and with the previous help, i see that in my virtual switch in domoticz now too. so i can actually see downstairs wether the airco unit upstairs is running or not. (which i could already in the smartthings app, but that is besides the point, i don't want many apps to run many things, i want one domoticz to run the world. (insert evil laughter)

but i only see those statuses/values when i click deploy. it does not seem to periodically update, eventhough i use a once a minute inject... not sure what that is about. the documentation of the node-red module https://flows.nodered.org/node/node-red ... martthings isn't really clear about it. (in fact, it doesn't really tell me much on how to use it....)

the switch in node can now also be used to turn the airco on and off. That is actually great. i can write to the airconditioner:
so this function node:

Code: Select all

var msg = {
    topic: "switch",
    payload: {
        value: 1
    }
}
return msg;
send to the switch will actually turn it on. 0 to turn off. that is a big milestone towards integrating the airconditioner into domoticz.

Then i start reading about getting a switch command from domoticz to node-red, and the gray enters my brain again. i just don't see how to do it. how do i get a simple 1 or 0 into mqtt so node-red picks it up to run the correct function node? i read a few pages, i read the wiki, but it doesn't really give a clear cut howto on how to do this.

in fact. i had to even try several times to get my mqtt-in node connected... seems to be ok now. but how to get anything in there? and how to see the trees for the forest. i get so much 'crap' from domoticz in domoticz/out. i think i need to create a specific topic for this switch. but how? and still, how to get a switch command in there from the domoticz switch? i see i can do on/off actions with http:// or script://. Does that mean that i have to put scripts in the ~/domoticz/scripts folder to do the switching? That is going to be messy when i also need scripts to set cooling/heating-mode, temperature, etc. etc.....(and those things need figuring out later).

so this is where i am currently:
Screenshot 2020-12-10 at 11.06.01.png
Screenshot 2020-12-10 at 11.06.01.png (101.1 KiB) Viewed 933 times
still a bit messy with way too many debug nodes. but work in progress.....

hopefully someone can give me a few pointers to take this further. thanks for all the help!
User avatar
FireWizard
Posts: 1801
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SmartThings Airconditioner

Post by FireWizard »

Hi, @wkossen,
well, that helped a lot. I can now see temp and hum in Domoticz.
Okay, that is nice and a step forward.
when should nvalue and svalue be used and why? i don't really get that, and i read the wiki. it does not really make a lot of
You should read: https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors and also: https://piandmore.wordpress.com/2019/02 ... -domoticz/
why is one toStrings() and the other not? in fact, why is there any toStrings() at all, as both values are numerical in nature.... maybe I'm trying logic and i shouldn't :/
Keep in mind, that nvalue always require a numerical value and svalue always require a string value.
A string value is always within quotes (" ").
So, "this is a string" and this is not a string. Similar 123 is a number, but "123" is not a number, but a string.
A string you can concatenate. So "Hello" + " world" will become "Hello world".
Similar 1 + 2 equals 3, but "1" + "2" equals "12".
Although both look like numbers, in all program languages the are different and should be handled different.
So if it is a number (123) and you need a string, you have to use the function toString() in order to make it a string.
but i only see those statuses/values when i click deploy. it does not seem to periodically update, even though i use a once a minute inject... not sure what that is about. the documentation of the node-red module https://flows.nodered.org/node/node-red ... mart things isn't really clear about it. (in fact, it doesn't really tell me much on how to use it....)
Can you post your flow?
i get so much 'crap' from domoticz in domoticz/out.
NO, you don't get 'crap'. You get the data of all the Domoticz devices. Not many people need them all, so you have to filter it.
i think i need to create a specific topic for this switch. but how? and still, how to get a switch command in there from the domoticz switch? i see i can do on/off actions with http:// or script://. Does that mean that i have to put scripts in the ~/domoticz/scripts folder to do the switching? That is going to be messy when i also need scripts to set cooling/heating-mode, temperature, etc. etc.....(and those things need figuring out later).

No, No and No

You simple should filter the switch, you need. Look what the IDX number of the switch is. Note it down.

Screenshot_Test switch.png
Screenshot_Test switch.png (8.2 KiB) Viewed 916 times
In the switch node, you place that IDX number. In this example 43

Screenshot_Test switch3.png
Screenshot_Test switch3.png (7.93 KiB) Viewed 916 times
If you do that, you will only see the messages from device 43, in this case the Switch
Screenshot_Test switch2.png
Screenshot_Test switch2.png (38.22 KiB) Viewed 916 times
If you compare both messages, you will see that the difference is the value behind nvalue.
If it is 1 means the switch is ON, if it is 0 means the switch is OFF.

The next step is to create a function node with something as follows:

Code: Select all

if msg.payload.nvalue === 1 {
do something
}
else if msg.payload.nvalue ===0  {
do something else
}
I hope this will help you further.

Regards
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: SmartThings Airconditioner

Post by wkossen »

Thanks for your elaborate reply. I am trying to learn all this.

I applied the switch node, but now i get nothing in the debug window when i press the switch in domoticz, while it was in there with the full debug of all domoticz mqtt things. i must be doing something wrong still. here is the little test flow:

Code: Select all

[{"id":"1377f6e7.df3e89","type":"tab","label":"Flow 6","disabled":false,"info":""},{"id":"441dd864.9dd988","type":"switch","z":"1377f6e7.df3e89","name":"Switch ID 261","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"261","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":340,"y":100,"wires":[["e81113fc.22efb"]]},{"id":"520940e4.475f8","type":"mqtt in","z":"1377f6e7.df3e89","name":"testing","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"cae262ab.45512","x":80,"y":140,"wires":[["a3409233.0df7a","441dd864.9dd988"]]},{"id":"e81113fc.22efb","type":"debug","z":"1377f6e7.df3e89","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":100,"wires":[]},{"id":"a3409233.0df7a","type":"debug","z":"1377f6e7.df3e89","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":140,"wires":[]},{"id":"cae262ab.45512","type":"mqtt-broker","name":"","broker":"192.168.0.5","port":"8883","tls":"9895f781.42a5e8","clientid":"","usetls":true,"compatmode":true,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9895f781.42a5e8","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"m2mqtt_srv.crt","keyname":"m2mqtt_srv.key","caname":"m2mqtt_ca.crt","servername":"","verifyservercert":false}]
any pointers?
User avatar
FireWizard
Posts: 1801
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SmartThings Airconditioner

Post by FireWizard »

Hi @wkossen.

You want to filter IDX 261 and that is a number. So you have to configure a number and not a string.

See below:

Screenshot_switch_node.png
Screenshot_switch_node.png (20.99 KiB) Viewed 902 times
Regards
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: SmartThings Airconditioner

Post by wkossen »

my first reaction was "oh stupid me"

then i changed the parameter to number, redeploy, nothing in debug when i press the switch in domoticz
so i changed the idx to "261" (with quotes) and set it to string. still nothing.
i checked the idx is correct, it is.

gradually i'm slipping into stark-raving-mad mode.... what is wrong? sorry for all the noob questions, but i just don't see what the heck i'm doing wrong..

and thanks for all the help.
User avatar
FireWizard
Posts: 1801
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SmartThings Airconditioner

Post by FireWizard »

Hi, @wkossen

msg.payload is a number. So you have to configure a number and the value (261 in this case) should be without any quotes. So no " " around it.

The second thing you should do is to configure your MQTT output node and set the "Output" to "a parsed JSON object".

This should give you the filtered output.

Regards
wkossen
Posts: 62
Joined: Friday 06 November 2020 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: SmartThings Airconditioner

Post by wkossen »

and now it works. i can turn on and off the airconditioner from within domoticz.

thank you so much.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests