ilcato / homebridge-mqttswitch

Homebridge accessory plugin that create an HomeKit Switch based on MQTT topics
Apache License 2.0
31 stars 41 forks source link

How to send "on" or "off" command #9

Closed DJ-Q closed 8 years ago

DJ-Q commented 8 years ago

I have this set up with a sonoff device but I can only get "off" to work. When I flick the switch to on or off position in Home app it only ever send the off command. My sonoff is expecting cmnd/sonoff/power on and cmnd/sonoff/power off as topic and message. This works fine from command line mosquitto_pub but I can't for the life of me figure out the correct syntax in my config.json file to make this happen. Any ideas?

ilcato commented 8 years ago

How do you configure it?

DJ-Q commented 8 years ago

Like this

{ "bridge": { "name": "Homebridge-02", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" },

"platforms": [
],
"accessories": [
{
        "accessory": "mqttswitch",
        "name": "BigLamp",
        "url": "mqtt://127.0.0.1",
                "username": "",
                "password": "",
                "caption": "Big Lamp",
                "topics": {
                        "statusGet": "stat/sonoff/power",
                        "statusSet": "cmnd/sonoff/power",
                        "onValue": "ON",
                        "offValue": "OFF"

                }
}

] }

ilcato commented 8 years ago

Just updated plugin to version 0.0.3. Upgrade and retry.

DJ-Q commented 8 years ago

Thank you for the reply, i have updated the plugin to 0.0.3 but it still not working. it still seems to sending "TRUE" or "FALSE" and not "ON" or "OFF" even though o have set the onvalue and offvalue

ilcato commented 8 years ago

Change the config this way: "accessories": [ { "accessory": "mqttswitch", "name": "BigLamp", "url": "mqtt://127.0.0.1", "username": "", "password": "", "caption": "Big Lamp", "topics": { "statusGet": "stat/sonoff/power", "statusSet": "cmnd/sonoff/power" }, "onValue": "ON", "offValue": "OFF" }

DJ-Q commented 8 years ago

How is that different to what I have already?

ilcato commented 8 years ago

The onValue and offValue must be outside the parenthesis of the topics field.

DJ-Q commented 8 years ago

That worked thank you for your help

Hucksleyy91 commented 5 years ago

Hey I can’t get this to work My config:

{
  "topics" : {
    "statusGet" : "stat/vegtablegardenwater/POWER",
    "statusSet" : "cmnd/vegtablegardenwater/power"
  },
  "accessory" : "mqtt-sprinkler",
  "qos" : "0",
  "caption" : "Garden",
  "integerValue" : "TRUE",
  "onValue" : "ON",
  "offValue" : "OFF",
  "name" : "TEST MANG",
  "url" : "192.168.1.192:1883"
}

I’ve tried changing everything

I downloaded an app on my iPhone and I can subscribe to mqtt topic and turn my switch on and off, but I can’t get the mqtt-sprinkler accessory to do it