[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.
SweetPants
Posts: 1477
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V3.8423
Location: The Netherlands
Contact:

Re: [90] MQTT Support

Post by SweetPants » Saturday 11 July 2015 17:15

leoncornelissen wrote:I tried it with http in front and also 127.0.0.1 but with no luck, Can somebody help me out.
Does your MQTT broker uses authentication? Then you have top setup username/password
Can you publish on a topic using mosquitto_pub and subscribe to the same topic using mosquitto_sub?

kylegordon
Posts: 96
Joined: Friday 01 November 2013 0:58
Target OS: Linux
Domoticz version: Trunk
Contact:

Re: [90] MQTT Support

Post by kylegordon » Saturday 11 July 2015 17:16

Mosquitto has two packages generally, mosquitto client, and mosquitto server. You need to ensure you have mosquitto server installed somewhere on the network.

It sounds like you don't have the server running, so you should double check what you installed and let us know :-)
1 x HP DL380 & KVM
1 x RPI
1 x RFXtrx433 V78
11 x LWRF Switches
1 x LIFX
2 x Echo Dots
6 x Byron PIRs
2 x Nexa PIRs
2 x Kodi
2 x ESP8266 MQTT
1 x GPIO/MQTT PIR
1 x GPIO(PWM)/MQTT LEDs
1 x GPIO(SPI)/MQTT LPD6803 LEDs
Lots of Node-Red glue

leoncornelissen
Posts: 30
Joined: Monday 27 April 2015 20:33
Target OS: Raspberry Pi
Domoticz version: 3.8258
Location: Netherlands
Contact:

Re: [90] MQTT Support

Post by leoncornelissen » Saturday 11 July 2015 17:30

I have installed the broker on the synology. I have created two python script running on my laptop, one as subscriber and one publisher, i verified that I can receive my messages published to the synology.

So the broker is up and running. Without authentication

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

Re: [90] MQTT Support

Post by SweetPants » Saturday 11 July 2015 18:03

I'm using the mosquitto broker on Ubuntu Linux and it is running fine. I can see the following MQTT messages in the log.

2015-07-11 17:58:11.350 Domoticz V2.2659 (c)2012-2015 GizMoCuz

2015-07-11 17:58:14.464 MQTT: Connecting to 192.168.24.250:1883
2015-07-11 17:58:14.465 RFXCOM: Using serial port: /dev/ttyUSB0
2015-07-11 17:58:14.564 MQTT: connected to: 192.168.24.250:1883
2015-07-11 17:58:14.665 MQTT: Subscribed

Be sure you connect to the bind address/port in your mosquitto config

leoncornelissen
Posts: 30
Joined: Monday 27 April 2015 20:33
Target OS: Raspberry Pi
Domoticz version: 3.8258
Location: Netherlands
Contact:

Re: [90] MQTT Support

Post by leoncornelissen » Sunday 12 July 2015 12:01

I tried with an activemq broker installed on my laptop but still the same... I wonder if the synology package supports it even though I can select the hardware device.

Is there something else I have to select or us every device update posted?

karman
Posts: 1
Joined: Sunday 09 August 2015 15:33
Target OS: Raspberry Pi
Domoticz version:
Location: South AFrica
Contact:

Re: [90] MQTT Support

Post by karman » Sunday 09 August 2015 15:44

Hi Guys

Very new to Domoticz and trying to see if I can use it in my current home automation "network". So far you guys use one MQTT topic to process all the commands/statuses etc, which is not really how MQTT was indented as far as I understand. Mqtt is best to use 1 topic per "info byte". IE, /house/bedroom/lights/light1 and then the payload will be on/off or if dimmer a dimming value (or fan speed, or temperature reading etc). Each light /device has its own topic and if you want to get all topics op fit the house you just use /house/# , or all lights in room /house/bedroom/lights/+ and get all of them.

Problems with current solution:
Cannot switch on multiple lights at same time, have to do one afte another and if you have 10 devices , that loooongg delay.
No last status if message was missed or device powers on, which mean you have to either repeat message whole time (slow) or on/off again.
No method on reading current Mqtt info on network (Like Solar inverter information, temperature sensors etc)

Is there any plans to extend this functionality ?

L:

Edit:

Sample feed from Solar (Victron) .. Will be very nice to be able to get this info onto Domoticz

/victron/Ac/ActiveIn/L1/V 231.910003662
/victron/Ac/ActiveIn/L1/I -7.59999990463
/victron/Ac/ActiveIn/L1/P -1421
/victron/Ac/Out/L1/V 231.910003662
/victron/Ac/Out/L1/I -7.88000011444
/victron/Ac/Out/L1/P -1441
/victron/Ac/Out/L1/F 50.1534500122
/victron/Ac/Grid/L1/Power -1421
/victron/Ac/ActiveIn/L1/V 231.470001221
/victron/Ac/ActiveIn/L1/P -1410
/victron/Ac/Out/L1/V 231.470001221
/victron/Ac/Out/L1/P -1430
/victron/Ac/Grid/L1/Power -1410

User avatar
gizmocuz
Posts: 8491
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: [90] MQTT Support

Post by gizmocuz » Sunday 16 August 2015 18:40

you can use node red for this ?
Quality outlives Quantity!

User avatar
rbisschops
Posts: 32
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: [90] MQTT Support

Post by rbisschops » Tuesday 25 August 2015 17:11

Hi All,

I'm a newby to Mosquitto. I installed a brand new RPi with latest image of Domoticz, which includes Mosquitto. Does anyone know if the command line clients (_pub and _sub) are also installed in the image.

Thx in advance

Ralph

Update: apparently this is not installed. I installed the Moquitto_client package, now it works.
1x Raspberry Pi B with P1 connection and weather underground
1x Raspberry Pi 2+ with RFXtrx433, many CoCo units and a Harmony Hub
MySensors with custom built watermeter sensors on Aquadis+

User avatar
rbisschops
Posts: 32
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: [90] MQTT Support

Post by rbisschops » Saturday 05 September 2015 14:26

I have two RPi's running Domoticz. These are now synced via the standard Domoticz mechanism (remote server). However this requires to keep both RPi's on the same version. So an update on only one is not possible. I could connect both RPi's to a Mosquitto broker. This enables different versions to work together via MQTT.

Problem: Both Domoticz RPi's use domoticz/in and domoticz/out. This causes a conflict in this case.

Solution: Extend the MQTT Client Gateway with LAN interface with the option to define a custom topic name to publish and subsibe to (like for example domoticz1, results in domoticz1/in in and domoticz1/out).

Any thoughts anyone?

Ralph
1x Raspberry Pi B with P1 connection and weather underground
1x Raspberry Pi 2+ with RFXtrx433, many CoCo units and a Harmony Hub
MySensors with custom built watermeter sensors on Aquadis+

maxtrash
Posts: 165
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by maxtrash » Monday 14 September 2015 0:01

I think your request makes sense. Maybe if you keep the id's unique for each instance it could work but still would be a bit clumsy

wildfire
Posts: 29
Joined: Friday 18 September 2015 11:04
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by wildfire » Friday 18 September 2015 11:34

Hi all,
im kinda new to this forum, i tried domoticz before but now i want to integrate it in my home and get some real work done.
i want to use it to control my central heating, i got all the valves installed and im working on the last part of my sensors.
this is where mqtt comes into play.
mqtt is light and easy to use, subscribe to a topic and send away, or receive the topic output.
the way mqtt is supported by domoticz is a bit robust atm.
is there a way to change this to be able to chose a topic per device, to receive as wel as send date please?
for domotics its ok to parse all the data till it gets someting of valeu, but for a small arduino node with a small memory its hard to parse all the date till the correct idx is send out and then parse all the output data to do what it has to.
using json is ok but also, again, if you have to set the small sensor node every time you want to change some settings in domoticz, its just a lot of work to reprogram the nodes each time.
exaple:
i have a node for each room, all these nodes send the same data: temp, humi, lux, movement
best would be that i can subscribe to /domoticz/in/garage/temp and so on, 'garage' being the hardware mqtt toppic name and 'temp' being the device mqtt topic name
for sending from domoticz using this same logic would make it easy you subscribe to domoticz/out/# it would give all the data send from domoticz.
but if you want just the output for a specific device like a lamp or a valve, you can subscribe to domoticz/out/garage/valve and only get the data when the valve has to open.

i hope you understand my frustration whit this. im trying to set up my nodes in each room but writing parse code for each node and putting the idx in it and change it every time you try someting new is a drag.

thanks for reading
Matthieu

maxtrash
Posts: 165
Joined: Tuesday 06 August 2013 1:31
Target OS: -
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by maxtrash » Friday 18 September 2015 13:11

Currently the MQTT-functionality in Domoticz is mainly a replication of the JSON-interface. Most of the time it needs something like Node.js to publish/republish messages. Did you have a look at the example flow here: https://www.domoticz.com/wiki/Flows ?

wildfire
Posts: 29
Joined: Friday 18 September 2015 11:04
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by wildfire » Saturday 19 September 2015 10:48

maxtrash,
i did not find this page before, thanks. its a good workaround for now.
still it would be nice to have more mqtt options in domotcz, i dont know if this will be added to domoticz some day?

rgouyet
Posts: 12
Joined: Friday 02 October 2015 8:23
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by rgouyet » Friday 02 October 2015 14:46

Does someone success in parsing domoticz MQTT message in openHAB ?

As all domoticz messages share the same topic, it's hard to filter the requested one...

I ddidn't success to give a working item configuration.
See this post on openHAB community forum.

Thanks

retel
Posts: 1
Joined: Monday 12 October 2015 19:03
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by retel » Monday 12 October 2015 20:00

I created user variable :
- Idx :1
- Variable name: test
- Variable type: integer
- Current value :0
I try to update value by sending mqtt command like this one: http://www.domoticz.com/wiki/MQTT#Set_a_User_Variable
In the domoticz log i have error

2015-10-12 19:40:34.756 MQTT: Topic: domoticz/in, Message: {"command": "setuservariable", "idx": 1, "value": "123" }
2015-10-12 19:40:34.757 Error: MQTT: unknown idx received!


Similar command working fine, when i send {"command": "switchlight", "idx": 2450, "switchcmd": "On" } all working good.

Is it possible to change value of uservariable by mqtt command ?

WimFey
Posts: 3
Joined: Tuesday 27 October 2015 19:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by WimFey » Tuesday 27 October 2015 19:39

Retel,

I'm getting the exact same error. The MQTT message: {"command": "setuservariable", "idx" : 1,"name" : "windspeed" , "type" : "1" , "value": "10"}

gives the following error in the Domoticz log:

2015-10-27 18:29:35.777 MQTT: Topic: domoticz/in, Message: {"command":"setuservariable","idx":1,"name":"windspeed","type":"1","value":"10"}
2015-10-27 18:29:35.778 Error: MQTT: unknown idx received!

...

Updating virtual sensors for example works perfectly ... . Also, leaving the "idx" out of it and just using the name doesn't work ...

Anyone?

djdamix
Posts: 3
Joined: Wednesday 07 October 2015 22:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by djdamix » Tuesday 27 October 2015 20:52

Same for me on user variable as well, whereas updating device values via MQTT is working fine :(

WimFey
Posts: 3
Joined: Tuesday 27 October 2015 19:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by WimFey » Wednesday 28 October 2015 8:24

Checked the code for MQTT.cpp and find the following (https://github.com/domoticz/domoticz/bl ... e/MQTT.cpp - +- at Line 268)

...
else if (szCommand == "switchscene")
{
if (root["idx"].empty())
goto mqttinvaliddata;
if (!root["idx"].isInt64())
goto mqttinvaliddata;

idx = (unsigned long long)root["idx"].asInt64();
result = m_sql.safe_query("SELECT Name FROM Scenes WHERE (ID==%llu)", idx);
if (result.empty())
{
_log.Log(LOG_ERROR, "MQTT: unknown idx received!");
return;
}
}
else if (szCommand == "setuservariable")
{
result = m_sql.safe_query("SELECT Name FROM UserVariables WHERE (ID==%llu)", idx);
if (result.empty())
{
_log.Log(LOG_ERROR, "MQTT: unknown idx received!");
return;
}
...

If you look at the difference between both cases, you can see there is - except for the validation rules - an assignment missing: "idx = (unsigned long long)root["idx"].asInt64();"

So this is probably a bug.

Added description to the Bugs / Problems forum

ermacmk
Posts: 3
Joined: Wednesday 28 October 2015 12:31
Target OS: Linux
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by ermacmk » Wednesday 28 October 2015 12:36

Hi. I'am studyng mqtt at moment and i have some doubts about how get status from my brocker (mosquitto). I consulted this page: https://eclipse.org/mosquitto/man/mosquitto-8.php but i don't know how i use the "$SYS" topics to get information about my brocker. I try subscriber like as: mosquitto_sub -d -t $SYS/broker/clients/total but don't works.

What i need do to take information/status about my brocker?

SevenW
Posts: 27
Joined: Sunday 16 August 2015 22:19
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by SevenW » Tuesday 08 December 2015 20:52

Is there a way to get a list of (all) devices through MQTT, and is there a way to create a virtual sensor or switch?

Looking at the code hardware/MQTT.cpp I believe one always has to know the idx, before the interface can be used.
Right?

Regards,
SevenW

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests