[90] MQTT Support

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

matteos1
Posts: 36
Joined: Monday 08 May 2017 17:29
Target OS: -
Domoticz version:
Contact:

Smappee MQTT Support

Post by matteos1 »

good morning, I have a problem for the management of smappee. https://www.smappee.com/eu_it/home.
recently smappee has changed the way to manage its switches using the mqtt protocol.
I attach the files that the service has sent to me.
somebody would be able to create a script to manage the switches using the mqtt protocol and how to implement it in domoticz?
Smappee local MQTT topics - 20180209 (1).pdf
(23 KiB) Downloaded 146 times
MQTT broker configuration on Smappee Plus Pro (1).pdf
Attachments
MQTT broker configuration on Smappee Plus Pro (1).pdf
(190.71 KiB) Downloaded 140 times
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

Re: MQTT Support

Post by jimbo213Mo »

Hello - I'm a newbie to Domoticz [my son is the teckie who set it up]
In the LOG I see these lines:

2018-10-29 12:25:46.885 MQTT: Topic: domoticz/in, Message: {"idx":4,"nvalue":0,"svalue":"-10.1"}
2018-10-29 12:28:46.295 MQTT: Topic: domoticz/in, Message: {"idx":2,"nvalue":0,"svalue":"-21.2"}

How do I tell WHAT EVENT is issuing them? [my son doesn't know either] ??
How do I tell which DEVICE is :2 and :4 ??

I've scanned the wiki and can't figure it out.
Thanks, Jim
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

In the device list (Settings->Devices) you can see the device index (Idx). This matches to the idx in your MQTT messages. Also watch the log of domoticz
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

Re: [90] MQTT Support

Post by jimbo213Mo »

@SweetPants
Thanks ... here's what I have from Setup > Devices

2 deepfreezer 14052 1 deep-freezer Temp LaCrosse TX3 -4.8 F - - Set Unused Rename Device Log 2018-10-30 14:16:45
4 garagefreezer 14054 1 garage-freezer-temp Temp LaCrosse TX3 10.8 F - - Set Unused Rename Device Log 2018-10-30 14:19:53

and from the logfile:

2018-10-30 14:16:45.255 MQTT: Topic: domoticz/in, Message: {"idx":2,"nvalue":0,"svalue":"-20.5"}
2018-10-30 14:19:53.875 MQTT: Topic: domoticz/in, Message: {"idx":4,"nvalue":0,"svalue":"-11.8"}

So that SOLVES the mystery of what IDX refers to - thanks so much.
QUESTION - The nvalue and svalue do not match the temperature shown in devices. Any idea why not?

Thanks in advance, Jim
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

jimbo213Mo wrote: Tuesday 30 October 2018 20:30 QUESTION - The nvalue and svalue do not match the temperature shown in devices. Any idea why not?
For Temp devices the nvalue( numeric value) is always 0, the svalue (string value) should reflect your device temp. Maybe Fahrenheit to Celcius conversion? You can set that under Settings->Meters/Counters. Default is Cecius.
jimbo213Mo
Posts: 8
Joined: Friday 26 October 2018 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: United States
Contact:

Re: [90] MQTT Support

Post by jimbo213Mo »

yes that's it ... thanks
-18C = -4F

in settings > meters/counters I have
Meter/Counter Setup
Temperature:
Display: Fahrenheit
Degree Days (Base Temperature): 18.0


There are three [3] other mentions of the garage-freezer
-- setup > device = shows Fahrenheit, type = TEMP, sub-type = LaCrosse TX3
-- temperature > garagefreezer > notifications = shows Fahrenheit

The third place [below] I can't get the TYPE field to show TEMP which would match the device.
TEMP is not in the dropdown !!

Does this assist you in helping me get the notification svalue converted from C to F?

Thanks for sticking with me
Jim
Attachments
GF setup-Hardware.png
GF setup-Hardware.png (13.74 KiB) Viewed 3043 times
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

hello mrf68 and to all,
here I have followed your little tutorial page 16 from Monday 02/2018 with a fictitious idx 178 sensor but nothing works: on the one hand, although at the exit of the 1st node named json I have this :

Code: Select all

{
   "Battery": 255,
   "RSSI": 12,
   "description": "",
   "dtype": "Usage",
   "id": "0000204",
   "idx": 25,
   "name": "Unknown",
   "nvalue": 0,
   "stype": "Electric",
   "svalue1": "22.5",
   "unit": 2
}
the idx 178 sensor does not appear or never in the right part (debug): is this normal?
And, at the exit of the function, I have the undefined svalue such as:

Code: Select all

"{" command ":" udevice "," idx ": 25," svalue ":" undefined "}"
(even with the idx 25). Where is the problem?

An idea?
mrf68

Re: [90] MQTT Support

Post by mrf68 »

Hello pat054,

I think you need to check your function node. You need to manually set the idx of the virtual sensor, not the idx of the original input. And don’t forget to put a 1 behind svalue as well (svalue1 instead of svalue).
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

Hello mrf68,

Thank you for your reply.

What exactly does your phrase mean " You need to manually set the idx of the virtual sensor, not the idx of the original input."?

For my part, I can not get the result. Here is my installation:
- for the MQTT node :
Server: 192.168.1.17:1883
Topic: domoticz/out

- for the JSON node :
Action: convert between JSON string & object
Property: msg.playload.svalue1

- for the node of the function :

Code: Select all

msg.payload = "{\" command \ ": \" udevice \ ", \" idx \ ": 178, \" svalue \ ": \" "+ (msg.payload.svalue1) +" \ "}";
return msg;
On the Domoticz side, the MQTT equipment is declared and the virtual sensor device (idx 178) is also declared in temperature.

I do not see where it stems except the interpretation of the sentence that I do not understand. In expectation to hear from you, Sincerely.
mrf68

Re: [90] MQTT Support

Post by mrf68 »

Hi pat054,
pat054 wrote: Saturday 29 December 2018 10:45
What exactly does your phrase mean " You need to manually set the idx of the virtual sensor, not the idx of the original input."?
As I saw in your example of the exit of the function, you used idx 25, which is the idx of the original sensor, as shown in the exit of your 1st node. I realised that I didn't make it clear enough that the function, where we rebuild the info that has to be processed by Domoticz, needs to have the idx of the virtual sensor that needs to be updated.

If I look at your new written function, you changed the correct part, so the idx of the virtual sensor is now correct (in my opinion).

I see some extra spaces in the code of the function, that can a problem. You could copy this:

Code: Select all

msg.payload = "{\"command\": \"udevice\", \"idx\": 178, \"svalue\": \"" + (msg.payload.svalue1) + "\"}";
... or change your existing code. There should be no spaces between \ and ". In your code for example, it says:

Code: Select all

: \" udevice \ ",
where it should be:

Code: Select all

 : \" udevice \",
Can you see the difference?

I hope this info helps. If not, don't hesitate to ask again. ;)

Oh, and I almost forgot: my little 'tutorial' does not mention the part where the info is being sent to Domoticz. When the output of the function is correct and going through the second JSON node, it needs to go into another MQTT node to your broker, with topic

Code: Select all

domoticz/in
Regards.
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

mrf68,
yes, I see the visual difference.

So I copied your line :

Code: Select all

msg.payload = "{\"command\": \"udevice\", \"idx\": 178, \"svalue\": \"" + (msg.payload.svalue1) + "\"}";
and replaced my line but nothing helps. After a Deploy, the result is always this (on the right of the screen) :

Code: Select all

{"command": "udevice", "idx": 178, "svalue": "undefined"}
I do not see where the problem can come from!

The problem would not come from the source: Domoticz? (my domoticz is in the latest beta version 4.10303)
When I put a msg.payload at the output of my MQTT (domoticz/out), in debug (on the right of the screen) I do not have in the idx 178 scroll: is this normal?
It is for this reason that in my previous posts I put an idx 25 (which appeared in debug (on the right of the screen)). But the same, I had the same result.
mrf68

Re: [90] MQTT Support

Post by mrf68 »

Hi pat054,
"svalue": "undefined"
This output means that this part

Code: Select all

(msg.payload.svalue1)
does not exist.

Instead of trying to solve things somewhere in the code, let's start from the beginning.

The exit of your first node says:

Code: Select all

{
   "Battery": 255,
   "RSSI": 12,
   "description": "",
   "dtype": "Usage",
   "id": "0000204",
   "idx": 25,
   "name": "Unknown",
   "nvalue": 0,
   "stype": "Electric",
   "svalue1": "22.5",
   "unit": 2
}
You see this probably in the debug tab as a result of the debug node. Change the Properties of that debug node to this:

Image

As a result it should show after receiving the next update from the sensor:

Image

It will probably show a different value, but it should show you a value. Is this working correctly?
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

mrf68,

ok, at the exit of the 1st node MQTT (domoticz / out), I connected a debug node (msg.payload.svalue1).
After a Deploy, the result is negative (on the right of the screen): domoticz / out: msg.payload.svalue1: undefined

While my 1st MQTT node is seen connected (green LED) below the node
mrf68

Re: [90] MQTT Support

Post by mrf68 »

Alright, we are getting somewhere.

The output of domoticz/out is every thing that crosses domoticz. We first need to capture the data from that one specific sensor.

Change the properties from the debug node back to normal (= msg.payload) and watch the data come in.

Can you do that and do you see some things flying by?
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

I redefined the properties of the debug node on normal (= msg.payload) and I observe the scrolled data. Here is an example :

Code: Select all

{
   "Battery": 255,
   "RSSI": 12,
   "description": "",
   "dtype": "General",
   "id": "0000044D",
   "idx": 140,
   "name": "CPU_Usage Raspberry",
   "nvalue": 0,
   "stype": "Percentage",
   "svalue1": "12.12",
   "unit": 1
}
Basically, I get idx 140 (as above) and idx 25, 27, 141, 142, 143, 144, 145, 146, 147..etc.
Etc. is actually limited to 25, 27,141,142,143,140,144,144,146,147. And that's about everything

I think Domoticz only sends idx (devices) that change state
mrf68

Re: [90] MQTT Support

Post by mrf68 »

So far so good. Now add a JSON node and a Switch node like this:

Image

Change the settings of the switch:

Image

... and put the desired idx in the empty fiels after az.

Then watch for the next update. And yes, Domoticz only shows an update in mqtt when the sensor sends an update to Domoticz.
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

mrf68,

I added the JSON node and the Switch node. And I changed the switch settings such as:

name: msg.payload.idx
== 0/9 140 (from idx)

After Deploy, I have this in the debug screen:

domoticz / out: 29/12/2018 at 16: 01: 53node: ad57d776.782158
domoticz / out: msg.payload.svalue1: string [5] "23.72".

Which corresponds to "Data": "23.72%" of the idx 140 device when the JSON code is entered in the browser: http://192.168.1.17:8080/json.htm?type=devices&rid=140.

So far it is going well.
mrf68

Re: [90] MQTT Support

Post by mrf68 »

Now add a function node:

Image

... and place in in the line before the debug node. My idx in this example is 368, you should change that to 178. Change the properties of the debug node to msg.payload, so you can see the whole message. It should look like this:

Image

This message will be the input for a virtual temp sensor. Add a MQTT out node and change the settings to your needs. So don't use this ipaddress since it's my local server. ;) What you should use is the topic domoticz/in.

Image

Then connect it to the function node like this:

Image

When a new message shows up in the debug tab, your Domoticz should receive this message as well. Check the virtual sensor if it updated correctly and if not check the Domoticz log.
pat054
Posts: 11
Joined: Monday 30 July 2018 15:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10102
Location: France
Contact:

Re: [90] MQTT Support

Post by pat054 »

mrf68,

I'm late because my Mosquitto on my Raspberry did not want to connect anymore. I had to reinstall it completely.

I approved your message such as:

- MQTT node domoticz / in:
server: 192.168.1.17:1883
topic: domoticz / in
QOS 2

- JSON node:
action: Convert between JSON string & object
property: msq.payload

- switch node:
property: msg.payload.idx
== 0/9 140

- Node of the function :

Code: Select all

msg.payload = "{\"command\": \"udevice\", \"idx\": 178, \"svalue\": \"" + (msg.payload.svalue1) + "\"}";
return msg;
- MQTT node domoticz / in:
server: 192.168.1.17:1883
topic: domoticz / in

- debug node:
output: msg.payload
to: debug windows

- The results are:
- pour the debug screen:

Code: Select all

"{"command": "udevice", "idx": 178, "svalue": "24,96"}"
- in domoticz:
the idx 140 gives data 24,96
the idx 178 gives data 24.96
the device idx 178 in the tab "temperature" gives 24.96 ° c
and the log gives:

Code: Select all

2018-12-29 18: 40: 20.622 MQTT: Topic: domoticz / in, Message: {"command": "udevice", "idx": 178, "svalue": "24.96"}
the problem is solved?
mrf68

Re: [90] MQTT Support

Post by mrf68 »

You end your post with a question mark? Did you solve your problem? :?:
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest