Replace mqtt "domoticz/out" with own topic

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!
Post Reply
tuxmartin
Posts: 10
Joined: Wednesday 06 September 2017 12:47
Target OS: Linux
Domoticz version:
Contact:

Replace mqtt "domoticz/out" with own topic

Post by tuxmartin » Thursday 21 September 2017 19:29

Hi,
I'm using esp easy that cannot parse json reply from "domoticz/out" topic.
Incoming data from hardware is ok. Only reply is problem.

Can I send from domoticz switch device data to custom mqtt topic?
Normally domoticz send:

Code: Select all

$ mosquitto_sub -v -h 10.123.1.18 -p 1883 -t '#'
domoticz/out {
   "Battery" : 255,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00014052",
   "idx" : 2,
   "name" : "Sonoff_1_internal_relay",
   "nvalue" : 1,
   "stype" : "Switch",
   "svalue1" : "0",
   "switchType" : "On/Off",
   "unit" : 1
}
But I need to send value "1" or "0" to custom topic like esp8266/DEVICE_NAME/gpio4 where DEVICE_NAME is different for each address.
I do not know how can I do it.

I can write python script, that parse domoticz/out and send data to esp8266/DEVICE_NAME/gpio4. Or create php file that publish to right topic and send this file url in "on/off action" at widget.
But they are the wrong solutions...

SweetPants
Posts: 1511
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V3.8590
Location: The Netherlands
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by SweetPants » Sunday 24 September 2017 19:56

You can use NodeRed for that, subscribe to domoticz/out and re-publish on your own topic. This gives you max flexibility

wim57
Posts: 4
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by wim57 » Monday 25 September 2017 13:05

You can also use a device 'Domoticz MQTT Helper' in ESP Easy.
This supports reading domoticz/out messages.

Edit: previous versions of ESP Easy could not process the message because of length but in 2.0.0 dev 11 that was fixed.

tuxmartin
Posts: 10
Joined: Wednesday 06 September 2017 12:47
Target OS: Linux
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by tuxmartin » Monday 25 September 2017 23:31

wim57 wrote:
Monday 25 September 2017 13:05
You can also use a device 'Domoticz MQTT Helper' in ESP Easy.
This supports reading domoticz/out messages.

Edit: previous versions of ESP Easy could not process the message because of length but in 2.0.0 dev 11 that was fixed.
How can I config Domoticz MQTT Helper?

I set it as at attachments.

Domoticz produces these jsons:

Code: Select all

[email protected]:~$ mosquitto_sub -v -h 10.123.1.18 -p 1883 -t '#'
domoticz/out {
   "Battery" : 255,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00014052",
   "idx" : 2,
   "name" : "Sonoff_1_relay1_230V",
   "nvalue" : 1,
   "stype" : "Switch",
   "svalue1" : "0",
   "switchType" : "On/Off",
   "unit" : 1
}

domoticz/out {
   "Battery" : 255,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00014052",
   "idx" : 2,
   "name" : "Sonoff_1_relay1_230V",
   "nvalue" : 1,
   "stype" : "Switch",
   "svalue1" : "0",
   "switchType" : "On/Off",
   "unit" : 1
}
But espeasy do nothing. Relay not work.

What I do bad?
Attachments
espeasy2.png
espeasy2.png (74.37 KiB) Viewed 321 times
espeasy1.png
espeasy1.png (45.87 KiB) Viewed 321 times

wim57
Posts: 4
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by wim57 » Tuesday 26 September 2017 10:26

I had some trouble with configuration too...
The status of the switch is represented by the 'nvalue' in the payload.
So I tried 'nvalue' as the value name in ESP and it works. I don't know if that is documented somewhere.

tuxmartin
Posts: 10
Joined: Wednesday 06 September 2017 12:47
Target OS: Linux
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by tuxmartin » Wednesday 27 September 2017 12:00

wim57 wrote:
Tuesday 26 September 2017 10:26
So I tried 'nvalue' as the value name in ESP and it works. I don't know if that is documented somewhere.
It's not working for me :-(


Why there is not IDX? I had set it.
domoticz_mqtt_helper.png
domoticz_mqtt_helper.png (55.39 KiB) Viewed 268 times

wim57
Posts: 4
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by wim57 » Thursday 28 September 2017 13:27

I do not see the IDX in the overview either, that probably a bug.
Does the log show anything (GPIO .. set to 0/1)?

tuxmartin
Posts: 10
Joined: Wednesday 06 September 2017 12:47
Target OS: Linux
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by tuxmartin » Thursday 28 September 2017 14:06

No, there is nothing in log:

Code: Select all

5749 : WIFI : mDNS started, with name: modul1_7.local
5804 : MQTT : Connected to broker
5807 : Subscribed to: /sonoff/modul1/#
5820 : EVENT: System#Boot
5839 : SW : State 0
5857 : EVENT: internal_relay#internal_relay=0.00
5947 : WD : Uptime 0 ConnectFailures 0 FreeMem 18928
5947 : EVENT: Clock#Time=Thu,12:01
35947 : WD : Uptime 1 ConnectFailures 0 FreeMem 18832
48005 : EVENT: Clock#Time=Thu,12:02
35927 : WD : Uptime 1 ConnectFailures 0 FreeMem 18832
51973 : EVENT: Clock#Time=Thu,12:05
65928 : WD : Uptime 1 ConnectFailures 0 FreeMem 18664
95929 : WD : Uptime 2 ConnectFailures 0 FreeMem 18664
112309 : EVENT: Clock#Time=Thu,12:06
125930 : WD : Uptime 2 ConnectFailures 0 FreeMem 18664
155931 : WD : Uptime 3 ConnectFailures 0 FreeMem 18664
172502 : EVENT: Clock#Time=Thu,12:07

tuxmartin
Posts: 10
Joined: Wednesday 06 September 2017 12:47
Target OS: Linux
Domoticz version:
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by tuxmartin » Thursday 28 September 2017 14:47

I tried firmware ESPEasy_R120_4096.bin instead of ESPEasy_v2.0.0-dev12_dev_4096.bin.

Still not working:
ESP_Easy_R120.png
ESP_Easy_R120.png (33.66 KiB) Viewed 231 times

wim57
Posts: 4
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi
Domoticz version:
Contact:

WellRe: Replace mqtt "domoticz/out" with own topic

Post by wim57 » Thursday 28 September 2017 18:13

Can it be your ESP is not subscribed to domoticz/out topic?
At least it is not shown in this log. Did you change settings of the controller?

salopette
Posts: 7
Joined: Tuesday 07 March 2017 22:03
Target OS: Raspberry Pi
Domoticz version: V3.6882
Location: Germany
Contact:

Re: Replace mqtt "domoticz/out" with own topic

Post by salopette » Monday 02 October 2017 11:11

Hello people can someone help me?
I'm totall new here.
How can I integrate this into Domoticz?
My English is not good and my programming language is not synonymous.
Please help!

https://github.com/thexperiments/esp826 ... tt_gateway

Think for all your help!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests