I'm trying to switch my lights with MQTT but I don't got it to work. Now I'm testing it with mosquitto_pub and the following occurs:
When I try command [1] only: nothing happened
[1] mosquitto_pub -h localhost -m '{"command": "switchlight", "idx": 310, "switchcmd": "Toggle" }' -t 'domoticz/in'
But when I enter command [2] after command [1]: the the light switched on:
[2] mosquitto_pub -h localhost -m '{"command": "getdeviceinfo", "idx": 310 }' -t 'domoticz/in'
what am I missing / doing wrong??
MQTT: executing 2 commands for switching light
Moderators: leecollings, remb0
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: MQTT: executing 2 commands for switching light
If you have your domoticz MQTT "hardware" configured with Prevent Loop True (the default) the incoming commandpedemo wrote: ↑Wednesday 26 August 2020 9:50 I'm trying to switch my lights with MQTT but I don't got it to work. Now I'm testing it with mosquitto_pub and the following occurs:
When I try command [1] only: nothing happened
[1] mosquitto_pub -h localhost -m '{"command": "switchlight", "idx": 310, "switchcmd": "Toggle" }' -t 'domoticz/in'
But when I enter command [2] after command [1]: the the light switched on:
[2] mosquitto_pub -h localhost -m '{"command": "getdeviceinfo", "idx": 310 }' -t 'domoticz/in'
what am I missing / doing wrong??
Code: Select all
mosquitto_pub -h localhost -m '{"command": "switchlight", "idx": 506, "switchcmd": "Toggle" }' -t domoticz/in
the incoming request
Code: Select all
mosquitto_pub -h localhost -m '{"command": "getdeviceinfo", "idx": 506 }' -t domoticz/in
Code: Select all
mosquitto_sub -F "%U - %t - %p" -v -p 1883 -t "#"
Code: Select all
1598431402.400431855 - domoticz/in - {"command": "getdeviceinfo", "idx": 506 }
1598431402.558232479 - domoticz/out - {
"Battery" : 255,
"RSSI" : 12,
"description" : "",
"dtype" : "Light/Switch",
"hwid" : "3",
"id" : "0001424A",
"idx" : 506,
"name" : "MQTT test",
"nvalue" : 0,
"stype" : "Switch",
"svalue1" : "0",
"switchType" : "On/Off",
"unit" : 1
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 17
- Joined: Saturday 04 May 2019 11:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V 2020.2
- Location: the Netherlands
- Contact:
Re: MQTT: executing 2 commands for switching light
Okay clear, but the command mosquitto_pub -h localhost -m '{"command": "switchlight", "idx": 310, "switchcmd": "Toggle" }' -t 'domoticz/in' doesn't toggle my light. How can I switch my light?
I'm a newby so forgive any "dumb" questions
I'm a newby so forgive any "dumb" questions
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: MQTT: executing 2 commands for switching light
I cannot replicate that, My lights do toggle from Off to On and vice-versa with that command.
How is your MQTT configured in domoticz?
What do yo see in the domoticz log when entering that command?
What do see when entering that command when you listen to port 1883 with
Code: Select all
mosquitto_sub -F "%U - %t - %p" -v -p 1883 -t "#"
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 17
- Joined: Saturday 04 May 2019 11:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V 2020.2
- Location: the Netherlands
- Contact:
Re: MQTT: executing 2 commands for switching light
Firts of all: many thanks for helping me!!
* Nothing is shown in the Domoticz log file when entering that command. When I exectue both commands the lights went on but nothing is shown in the log
* When entering command: mosquitto_sub -F "%U - %t - %p" -v -p 1883 -t "#" it stated a bunch of info
i.e.
* What is the deviceType / subtype of your device as seen on the device tab in domoticz?
I don't know where to find it (maybe you can put it here in Dutch because I'm using it in Dutch
* I install it with sudo install mosquittowaaren wrote: ↑Wednesday 26 August 2020 11:16 How is your MQTT configured in domoticz?
What do yo see in the domoticz log when entering that command?
What do see when entering that command when you listen to port 1883 with
CODE: SELECT ALL
mosquitto_sub -F "%U - %t - %p" -v -p 1883 -t "#"
What is the deviceType / subtype of your device as seen on the device tab in domoticz?
* Nothing is shown in the Domoticz log file when entering that command. When I exectue both commands the lights went on but nothing is shown in the log
* When entering command: mosquitto_sub -F "%U - %t - %p" -v -p 1883 -t "#" it stated a bunch of info
i.e.
Code: Select all
1598435533.506968029 - domoticz/out - {
"Battery" : 255,
"RSSI" : 12,
"description" : "",
"dtype" : "P1 Smart Meter",
"hwid" : "10",
"id" : "1",
"idx" : 244,
"name" : "Power",
"nvalue" : 0,
"stype" : "Energy",
"svalue1" : "1401695",
"svalue2" : "1671932",
"svalue3" : "312",
"svalue4" : "0",
"svalue5" : "357",
"svalue6" : "0",
"unit" : 1
}
1598435533.607205366 - domoticz/out - {
"Battery" : 255,
"RSSI" : 12,
"description" : "",
"dtype" : "General",
"hwid" : "10",
"id" : "00000001",
"idx" : 245,
"name" : "Voltage L1",
"nvalue" : 0,
"stype" : "Voltage",
"svalue1" : "234.200",
"unit" : 1
}
I don't know where to find it (maybe you can put it here in Dutch because I'm using it in Dutch
-
- Posts: 17
- Joined: Saturday 04 May 2019 11:29
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V 2020.2
- Location: the Netherlands
- Contact:
Re: MQTT: executing 2 commands for switching light
I figured it out by myself. In DOMOTICZ | HARDWARE I edited my MQTT GATEWAY
I set the 'Prevent Loop' from TRUE to FALSE (see attachment) and now it reacts on the first command
I set the 'Prevent Loop' from TRUE to FALSE (see attachment) and now it reacts on the first command
- Attachments
-
- 2020-08-26_14-01-47.png (39.94 KiB) Viewed 1048 times
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: MQTT: executing 2 commands for switching light
Just switch to English for a moment
this is not describing /showing how you configured MQTT in domoticz.* I install it with sudo apt install mosquitto
I mean this page If you don't see anything in the log it could mean that the commands are not received by domoticz or that your logging does not show the normal / status log. What is the output of
Code: Select all
grep DAEMON /etc/init.d/domoticz.sh | grep log
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest