Light does not switch on with MQTT Topic is solved

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
User avatar
Gaijin66
Posts: 5
Joined: Thursday 20 December 2018 0:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Light does not switch on with MQTT

Post by Gaijin66 »

Hello everyone,

I have a Raspberry Pi 3B+. There is a RFXtrx433 connected on the USB port. I have led lights plugged in a KaKu / CoCo switch. It is programmed to switch on at sunset an switch off at 00:00. That works perfectly. Switching on and off by clicking on it also works good. When i give the command:

Code: Select all

mosquitto_pub -h localhost -m '{ "idx" : 3, "nvalue" : 1 }' -t 'domoticz/in'
it switches the light on on the dashboard, but the actual light does not go on. Same goes for turning off.
Domoticz and MQTT communicates on port 1338.
Maybe i did not give all the necessary information. Send me in the right direction, please. What can i do?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by waaren »

Gaijin66 wrote: Thursday 20 December 2018 0:55 Maybe i did not give all the necessary information. Send me in the right direction, please. What can i do?
What is the result if you enter

Code: Select all

mosquitto_pub -t domoticz/in -m {"command": "switchlight", "idx": 3, "switchcmd": "On" } 
?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Gaijin66
Posts: 5
Joined: Thursday 20 December 2018 0:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by Gaijin66 »

Hello waaren,

Thanks for the reply.

I did not try that, but i will. I will come back on that.
User avatar
Gaijin66
Posts: 5
Joined: Thursday 20 December 2018 0:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by Gaijin66 »

It says:

Code: Select all

Error: Unknown option 'switchlight,'.
When I give the command:

Code: Select all

curl "http://192.168.0.5:8080/json.htm?type=command&param=switchlight&idx=3&switchcmd=Off"
It says:

Code: Select all

{
   "status" : "OK",
   "title" : "SwitchLight"
}
The actual light goes on.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by waaren »

Gaijin66 wrote: Thursday 20 December 2018 22:05 It says:

Code: Select all

Error: Unknown option 'switchlight,'.
Sorry forgot the single quotes

Code: Select all

mosquitto_pub -t domoticz/in -m '{"command": "switchlight", "idx": 3, "switchcmd": "On" }'
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
l0gic
Posts: 107
Joined: Tuesday 08 October 2013 9:35
Target OS: Linux
Domoticz version: Latest
Contact:

Re: Light does not switch on with MQTT

Post by l0gic »

Looks like you may have a capitalisation issue,
Domoticz responds with 'SwitchLight' you are sending 'switchlight'

May be worth a try...

Kevin
Non credus crepitus
User avatar
Gaijin66
Posts: 5
Joined: Thursday 20 December 2018 0:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by Gaijin66 »

No problem, i also made that mistake :oops:

But that command really works. The actual light goes on. Thanks

Why did

Code: Select all

mosquitto_pub -h localhost -m '{ "idx" : 3, "nvalue" : 1 }' -t 'domoticz/in'
turned the light only on the dashboard on?

@Kevin:
The single quotes was the mistake, but thanks for the reply.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by waaren »

Gaijin66 wrote: Thursday 20 December 2018 23:28 Why did

Code: Select all

mosquitto_pub -h localhost -m '{ "idx" : 3, "nvalue" : 1 }' -t 'domoticz/in'
turned the light only on the dashboard on?
I think this works as designed to enable two way communication without causing an infinite loop. There are some quite old discussions here on the forum about this subject but I have not found a clear and definite answer.
What I see when sniffing mqtt with

Code: Select all

mosquitto_sub -F "%U - %t - %p" -v -t '#' 
sending the command

Code: Select all

mosquitto_pub -t domoticz/in  -m '{ "idx" : 249, "nvalue" : 1 }'

Code: Select all

1545380550.427604212 - domoticz/in - { "idx" : 249, "nvalue" : 0 }
1545380550.552579044 - domoticz/out - {
   "Battery" : 255,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00EC0A7A",
   "idx" : 249,
   "name" : "testLight",
   "nvalue" : 0,
   "stype" : "AC",
   "switchType" : "On/Off",
   "unit" : 11
}
switching the light in domoticz GUI

Code: Select all

1545380976.211775471 - domoticz/out - {
   "Battery" : 255,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00EC0A7A",
   "idx" : 249,
   "name" : "testLight",
   "nvalue" : 1,
   "stype" : "AC",
   "svalue1" : "99",                             <<<<==== different then via the nvalue command
   "switchType" : "On/Off",
   "unit" : 11
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Gaijin66
Posts: 5
Joined: Thursday 20 December 2018 0:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Light does not switch on with MQTT

Post by Gaijin66 »

Ok. This is helpful. From now on i use the code you provided.

I can consider the matter solved. This topic can be closed.
SweetPants

Re: Light does not switch on with MQTT

Post by SweetPants »

Gaijin66 wrote: Friday 21 December 2018 17:55 I can consider the matter solved. This topic can be closed.
You can mark it solved yourself
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest