JSON + MQTT

Moderator: leecollings

Post Reply
ddragas
Posts: 3
Joined: Friday 14 July 2017 11:23
Target OS: Linux
Domoticz version:
Contact:

JSON + MQTT

Post 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
User avatar
jvdz
Posts: 2330
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: JSON + MQTT

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
ddragas
Posts: 3
Joined: Friday 14 July 2017 11:23
Target OS: Linux
Domoticz version:
Contact:

Re: JSON + MQTT

Post by ddragas »

Hi
thnx for your reply … but still without success … I really need to sort out how to properly trigger switch …
ddragas
Posts: 3
Joined: Friday 14 July 2017 11:23
Target OS: Linux
Domoticz version:
Contact:

Re: JSON + MQTT

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest