mydevbox / hubitat-mqtt-link

MIT License
26 stars 16 forks source link

Unable to send message to have Hubitat change a virtual switch #9

Open TomMcBride opened 1 year ago

TomMcBride commented 1 year ago

I've been using mqtt-link for a good while to send status messages for several of my devices to other programs. I now need to be able to send a message to mqtt-link to change a switch from off to on but have not been successful no matter what I try. I've reviewed all the documentation and I think I'm sending the message to the correct topic. I'm using the following in Python:

client.publish("hubitat/hubitat-hub-000d/testswitch-215",payload="on")

Can you help? I'd sure appreciate it.

Tom

NoxHarmonium commented 11 months ago

I was having the same issue today. I'm not sure if it is in the documentation and I just missed it, but you need to put cmd in the topic name.

For example if the topic I used to get the current state of a switch is:

hubitat/lounge-hub-hub-000d/tv-plug-12/switch

The topic I need to use to update it's state is:

hubitat/lounge-hub-hub-000d/tv-plug-12/cmd/switch

So in home-assistant my config would be:

mqtt:
  - switch:
      unique_id: tv_plug
      state_topic: "hubitat/lounge-hub-hub-000d/tv-plug-12/switch`"
      command_topic: "hubitat/lounge-hub-hub-000d/tv-plug-12/cmd/switch"
      state_on: "on"
      state_off: "off"
      payload_on: "on"
      payload_off: "off"

I needed to specify the state_on, payload_on etc. because hubitat-mqtt-link uses lower case payloads, and home-assistant seems to use uppercase payloads by default.

Hope that helps other people having the same issue!

I'll have another look at the README and maybe look at raising a PR if this is missing.