Page 11 of 19

Re: [90] MQTT Support

Posted: Saturday 11 July 2015 17:15
by SweetPants
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?

Re: [90] MQTT Support

Posted: Saturday 11 July 2015 17:16
by kylegordon
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 :-)

Re: [90] MQTT Support

Posted: Saturday 11 July 2015 17:30
by leoncornelissen
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

Re: [90] MQTT Support

Posted: Saturday 11 July 2015 18:03
by SweetPants
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

Re: [90] MQTT Support

Posted: Sunday 12 July 2015 12:01
by leoncornelissen
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?

Re: [90] MQTT Support

Posted: Sunday 09 August 2015 15:44
by karman
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

Re: [90] MQTT Support

Posted: Sunday 16 August 2015 18:40
by gizmocuz
you can use node red for this ?

Re: [90] MQTT Support

Posted: Tuesday 25 August 2015 17:11
by rbisschops
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.

Re: [90] MQTT Support

Posted: Saturday 05 September 2015 14:26
by rbisschops
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

Re: [90] MQTT Support

Posted: Monday 14 September 2015 0:01
by maxtrash
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

Re: [90] MQTT Support

Posted: Friday 18 September 2015 11:34
by wildfire
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

Re: [90] MQTT Support

Posted: Friday 18 September 2015 13:11
by maxtrash
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 ?

Re: [90] MQTT Support

Posted: Saturday 19 September 2015 10:48
by wildfire
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?

Re: [90] MQTT Support

Posted: Friday 02 October 2015 14:46
by rgouyet
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

Re: [90] MQTT Support

Posted: Monday 12 October 2015 20:00
by retel
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 ?

Re: [90] MQTT Support

Posted: Tuesday 27 October 2015 18:39
by WimFey
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?

Re: [90] MQTT Support

Posted: Tuesday 27 October 2015 19:52
by djdamix
Same for me on user variable as well, whereas updating device values via MQTT is working fine :(

Re: [90] MQTT Support

Posted: Wednesday 28 October 2015 7:24
by WimFey
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

Re: [90] MQTT Support

Posted: Wednesday 28 October 2015 11:36
by ermacmk
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?

Re: [90] MQTT Support

Posted: Tuesday 08 December 2015 19:52
by SevenW
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