Page 1 of 1

JSON + MQTT

Posted: Friday 15 December 2017 8:04
by ddragas
Hi all

I'm having problem with publishing MQTT message to Domoticz and running script that is behind that switch.

Switch type is Selector Switch (multiple values) that behind every value has a script that is executed. This switch normally works trough Domoticz interface and script is being triggered, and this is same action I need to be executed when sending JSON trough MQTT.

this is JSON which I'm executing when I want heat to turn off

Code: Select all

mosquitto_pub -t "domoticz/in" -m '{ "command": "udevice", "idx": 66, "nvalue": 0, "svalue1": "0" }'
and after executing code from above I get strange behaviour.

Both buttons are selected as active (Off and Heat)
https://ibb.co/mYe6Zm

when I click button from domoticz interface, in mqtt subscribe I get this JSON

Code: Select all

domoticz/out {
   "Battery" : 255,
   "LevelActions" : "script%3A///home/pi/domoticz/scripts/aircon.php%201|script%3A///home/pi/domoticz/scripts/aircon.php%20aircon_on|script%3A///home/pi/domoticz/scripts/aircon.php%20aircon_mode_dry|script%3A///home/pi/domoticz/scripts/aircon.php%20aircon_mode_cool|script%3A///home/pi/domoticz/scripts/aircon.php%20aircon_mode_heat",
   "LevelNames" : "Off|On|Dry|Cool|Heat",
   "LevelOffHidden" : "false",
   "RSSI" : 12,
   "SelectorStyle" : "0",
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00014092",
   "idx" : 66,
   "name" : "Air Condition",
   "nvalue" : 0,
   "stype" : "Selector Switch",
   "svalue1" : "0",
   "switchType" : "Selector",
   "unit" : 1
}
what am I doing wrong?

thnx in advance

Re: JSON + MQTT

Posted: Friday 15 December 2017 8:46
by jvdz
Doesn't this Selector switch also act as an DImmer which requires an On;Off or Set Level command?
I am not that familiar with MQTT, but is it "svalue1" or "svalue"?
Something like:
mosquitto_pub -t "domoticz/in" -m '{ "command": "udevice", "idx": 66, "nvalue": 0, "svalue": "Off" }'
mosquitto_pub -t "domoticz/in" -m '{ "command": "udevice", "idx": 66, "nvalue": 10, "svalue": "Set%20Level" }

Jos

Re: JSON + MQTT

Posted: Friday 15 December 2017 18:44
by ddragas
Hi
thnx for your reply … but still without success … I really need to sort out how to properly trigger switch …

Re: JSON + MQTT

Posted: Friday 15 December 2017 19:58
by ddragas
I've managed to trigger switch with command

Code: Select all

mosquitto_pub -t "domoticz/in" -m '{"command": "switchlight", "idx": 66, "switchcmd": "Set Level", "level":"40"}'
if some else need it

Cheers and thnx for help