[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

SchattenMann
Posts: 73
Joined: Friday 09 October 2015 19:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by SchattenMann »

don't think you can, you'll need to use http instead
sj3fk3
Posts: 23
Joined: Sunday 22 March 2015 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by sj3fk3 »

y1ann1s wrote: The only thing I am missing is to get a list of all devices in MQTT
afaik that's not the way a message queue works. It only outputs what "you" put in there and there is no command to send all devices down the pipe. You could trigger all devices and that would make sure that all devices are updated (and put on the queue).
SchattenMann
Posts: 73
Joined: Friday 09 October 2015 19:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by SchattenMann »

Are there any plans to continue improving MQTT supported commands such as setcolbrightnessvalue?
Vandaag
Posts: 5
Joined: Saturday 16 November 2013 23:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by Vandaag »

Hello,

Currently I am using 2 Domoticz connected to the same MQTT broker. The problem is that I cannot make a distinction from which domoticz server the messages are originating and I am unable to direct messages to a specific domoticz server. Would there be a possibility to extent the MQTT configuration to override the default groupname if needed?

Regards,

Richard
juha
Posts: 1
Joined: Sunday 23 April 2017 18:20
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by juha »

Can someone help with this one..?

I´ve done Motorized rollerblind HW and trying to add that one to Domoticz.
https://www.instructables.com/id/Motori ... ler-Blind/

I can publish MQTT messages with my cellphone and MMQT.FX and it does work, but how to add this to Domo?
I´m totally n00b with the Domoticz as well.. Broker does work, Mosquitto installed to same RPi than Domoticz. There is an example on tutorial how to use it with OpenHAB, but how with Domoticz is not clear at all.

Item:

Dimmer masterbedr_blind1 "Rullgardin 1" <rollershutter> { mqtt=">[ohab:/house/masterbedroom/rollerblind/0/set:command:*:${command}],<[ohab:/house/masterbedroom/rollerblind/0/status:state:default]" }

Sitemap:

Slider item=masterbedr_blind1
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: [90] MQTT Support

Post by Antori91 »

Hello,
It seems that we can't get using MQTT the SunRise SunSet Time. When I publish to domoticz/in topic the following command {"command": "getSunRiseSet"}, Domoticz don't answer to the request. Notice that my need is to get the Domoticz server date/time, so if there is another way than the getSunRiseSet command, please tell me.
Regards,
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

Read the Wiki and use JSON https://www.domoticz.com/wiki/Domoticz_ ... nset_times

/json.htm?type=command&param=getSunRiseSet

{
"ServerTime" : "Sep 30 2013 17:15:21",
"Sunrise" : "07:38:00",
"Sunset" : "19:16:00",
"status" : "OK",
"title" : "getSunRiseSet"
}
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: [90] MQTT Support

Post by Antori91 »

SweetPants, I red the wiki and know JSON commands. I know that GetSunRise works with HTTP/JSON. I used a lot these JSON commands for a previous DIY project. For a new project, I use MQTT to interface ESP8266 boards with Domoticz, so my question is MQTT relating and NOT JSON.
By the way, do you really read the questions before answering?
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

Antori91 wrote:Hello,
It seems that we can't get using MQTT the SunRise SunSet Time. When I publish to domoticz/in topic the following command {"command": "getSunRiseSet"}, Domoticz don't answer to the request. Notice that my need is to get the Domoticz server date/time, so if there is another way than the getSunRiseSet command, please tell me.
Regards,
Yes, i read the question you tried using MQTT {"command": "getSunRiseSet"} which does not work and asked for another way to get the server date/time, hence i answered. There is no word mentioned in your question that you used JSON already.

And if you want to use MQTT, you can't for this command
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: [90] MQTT Support

Post by Antori91 »

OK SweetPants.


PS : my "business case" is the following. I use ESP8266 boards (nodeMCU/Lua/MQTT) to manage Heaters (power up/down and consumption measure using ACS712). They have to know which electricity meter tariff is to use depending on hours. I solve the issue by using a virtual protected selector switch. This selector switch is switched (to reflect the tariff in use) by a time event on Domoticz side. Then, the ESP8266 can know the tariff by requesting Domoticz via MQTT ({"command": "getdeviceinfo", "idx": XX }). ...This is to avoid using the RTC Time Module on ESP8266/NodeMCU side...
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
User avatar
Antori91
Posts: 136
Joined: Sunday 12 February 2017 17:12
Target OS: NAS (Synology & others)
Domoticz version: 4.10717
Location: France
Contact:

Re: [90] MQTT Support

Post by Antori91 »

Hello,
After a bad news (getSunRiseSet not supported) a good news. According to documentation, logmessage is not supposed to work with MQTT channel, but it actually works. {"command" : "addlogmessage", "message" : "MyMessage to log"} to publish. I find this usefull to publish service messages (like lwt MQTT broker message) to Domoticz log.
Domoticz High Availability Cluster: Synology Dz V4.10693 (Main) - Raspberry Dz V4.10717 (Backup) - Scripts Node.js
Alarm server: Raspberry - motionEye - iot_ALARM-SVR Node.js
Sensors/Actuators: ESP8266-Arduino
https://github.com/Antori91/Home_Automation
User avatar
mvveelen
Posts: 678
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: [90] MQTT Support

Post by mvveelen »

How would one use, for instance, switching in LUA ?

On my Synology I have to browse to the right folder and type:

Code: Select all

root@DiskStation:/volume1/@appstore/mosquitto/bin# ./mosquitto_pub -h 192.168.0.124 -t 'domoticz/in' -m '{"command": "switchlight", "idx": 4128, "switchcmd": "On"}'
How can I use the MQTT command in a LUA script ?
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
Wob76
Posts: 110
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by Wob76 »

Hi,

Very new to both Domoticz and MQTT. So it is likely I am missing something, but I have searched as best I can.

I am using NodeRed to build some flows to talk to a webpage that controls my Aircon, I first created a flow linked to dummy switches I created in Domoticz, those switched link to the functions on the webpage and it is working great.

I am now building a flow to read the states from the webpage and update the switches to match, this way any changes made to the AC outside of Domoticz will be shown, this is handy if I use the AC App or the control panel itself. This is working, and I have a filter so MQTT messages are only sent if the unit has had a change on the since the last time I polled the page.

But, my issue is, that any update I send to Domonticz/In is then repeated on Domonticz/Out, this then causes my other flow to send updates to the web page to set the states, this is redundant, as it is where I read the states from, and I want to reduce the traffic I send to the page as much as possible. So, is it possible to stop Domoticz from sending MQTT updates for switches that have just been update via MQTT, or doesn't anyone know how I might filter these changes?

Thanks,
Wob
mrf68

Re: [90] MQTT Support

Post by mrf68 »

Hi Wob,

you read the states of the page, so it can tell if there is a difference before sending the commands. You want to minimize the data exchange to the page, so if a message comes from domoticz/out, let node-red check wether the status you have read from the page earlier is different or not. If not, then do nothing, if things are different then update the page.

Maybe another possibility is to add a variable in node-red. When a message is sent from domoticz/in to set a specific switch or setting, set a variable to 1 and read that variable when the same switch or setting is mentioned in a message from domoticz/out. If so, don't send an update to the page but do set the variable to 0 (values 0 and 1 are examples).

Regards,
Martin
Wob76
Posts: 110
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by Wob76 »

Hi Martin,

Thanks for the reply, I am using two different flows for data in\out of domoticz so my payload is different, being fairly new to all of this I am sure I am not doing things in the most efficient ways, but I am happy that it is talking.

I did think about storing the state of each switch in variables in nodered, but it seemed redundant since domoticz is already doing that. and I thought it odd that it would issues a MQTT update for a device that it has been updated via MQTT. Just thought I might be missing something, but if this is normal behaviour I'll look at a filtering solution in nodered.

While I am asking dumb questions, can someone just confirm my MQTT formatting.
For the AC I have a number of on\off switches, a couple of selector switches, a temperature and a thermostat.

ON\OFF are easy enough, I issue { "idx" : 30, "nvalue" : 1 } with idx = the the switch and nvalue 0 or 1 for off\on.

The selectors are { "idx" : 29, "svalue" : "10" } with the values as per the switch settings in 10 increments. I needed to ensure my svalue was sent as a strong and not a integer for it to work. I don't set the nvalue on these it just appears to stay as "2", they have no off state. Can anyone tell me what the nvalue does on selectors?

With the Thermostat, I am using the "Dummy" Thermostat, but it takes half degree changes, my AC unit does not, can anyone point me in the right direction on how I can modify it to only accept round numbers?

Thanks,
Wob
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: [90] MQTT Support

Post by salopette »

Hello, can someone help me remove my device from domoticz?
It was a virtual switch 205, which I have from the hardware etnfertn, but it still come complaining about MQTT purely.
How can I delete this?

RFLink Detected, Version: 1.1 Revision: 48 Build: 4
2017-10-21 16:36:41.301 MQTT: Subscribed
2017-10-21 16:36:41.402 MQTT: Topic: domoticz/in, Message: {"idx": 205, "nvalue": 0, "svalue": ""}
2017-10-21 16:36:41.402 Error: MQTT: unknown idx received!

I can not find this switch nowhere!
And also other switches do not have this IDx 205

Thank you!
wim57
Posts: 16
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: [90] MQTT Support

Post by wim57 »

Well, something other than Domoticz (maybe ESP8266?) may be publishing a message for idx 205.
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: [90] MQTT Support

Post by salopette »

No I have no other devices on the net which communicate via Mqtt.
the problem but already solved I believe!

sudo service mosquitto stop
sudo rm /var/lib/mosquitto/mosquitto.db
sudo service mosquitto start
User avatar
mvveelen
Posts: 678
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: [90] MQTT Support

Post by mvveelen »

mvveelen wrote: Monday 31 July 2017 18:44 How would one use, for instance, switching in LUA ?

On my Synology I have to browse to the right folder and type:

Code: Select all

root@DiskStation:/volume1/@appstore/mosquitto/bin# ./mosquitto_pub -h 192.168.0.124 -t 'domoticz/in' -m '{"command": "switchlight", "idx": 4128, "switchcmd": "On"}'
How can I use the MQTT command in a LUA script ?
Anyone?

The problem I'm facing: I have a Sonoff with Tasmota which is switched from Domoticz using MQTT (at least, I THINK it works that way, because I don't have any http URL's in the On / OFF settings of the switch). Sometimes the Sonoff loses the connection to my WiFi network and when Domoticz tells the Sonoff to switch, this switching isn't issued when the Sonoff comes back online in the WiFi network. I would expect it to issue the last switch command , but it doesn't.

How to fix ?
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
SweetPants

Re: [90] MQTT Support

Post by SweetPants »

mvveelen wrote: Saturday 04 November 2017 19:14 The problem I'm facing: I have a Sonoff with Tasmota which is switched from Domoticz using MQTT (at least, I THINK it works that way, because I don't have any http URL's in the On / OFF settings of the switch). Sometimes the Sonoff loses the connection to my WiFi network and when Domoticz tells the Sonoff to switch, this switching isn't issued when the Sonoff comes back online in the WiFi network. I would expect it to issue the last switch command , but it doesn't.

How to fix ?
You have to send the message as a retained message so the broker can send it after re-connect. Domoticz itself does not know that your sonoff was disconnected
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest