mikekap / wink-mqtt-rs

MQTT Relay for the Jailbroken Wink Hub v1, with Home Assistant MQTT autodiscovery support
Other
14 stars 0 forks source link

Discovery not working with Home Assistant #40

Open vrelk opened 3 years ago

vrelk commented 3 years ago

This looks like it may be related to #34.

I was having issues with zigbee2mqtt pairing to devices, but HA was finding them just fine, so I am going to use it for reference.

It looks like when wink-mqtt-rs is publishing to the config topic, it isn't using a retained message (zigbee2mqtt does this). So far, this is the main thing I can think of as to why HA isn't discovering any devices from wink-mqtt-rs, while it does from zigbee2mqtt. It also didn't create a config topic for the plug until after I restarted the wink-mqtt-rs process. There also seems to be a sizeable difference in the json data between ones that work, and ones that don't.

I did manually send the config message with the retain flag, and it still didn't work, so I'm thinking there's an issue with the format of the json data. (See the gist links below with the comparison to zigbee2mqtt, which works fine).

-s mqtt://wink:**********@**********
-d 'homeassistant'
--discovery-listen-topic 'homeassistant/status'

Note: I only added discovery-listen-topic after noticing the config issue to see if it would help. It did not.

Comparison of config messages (formatted): https://gist.github.com/vrelk/044e490b01ecd7dbedac1386da263b04 Comparison of state messages (formatted): https://gist.github.com/vrelk/57a0fa756dd081f43f9afe40ff31eccb Debug level logs: https://gist.github.com/vrelk/f1c018a8937b2ae2e393c519e44660ee

Summary:

froohoo commented 3 years ago

Is it possible you are getting auth errors in your broker log in HA (I am guessing you are using Mosquitto)?

vrelk commented 3 years ago

I haven't seen any errors in the HA logs, though I am unsure if I need to look in something other than the log section in the UI. As for the mqtt connection in HA. That works fine as it works with other things. I have a standalone Mosquito server running, and although I have separate users for everything, they all have full access.

On Thu, May 27, 2021, 2:53 PM Forrest Edwards @.***> wrote:

Is it possible you are getting auth errors in your broker log in HA (I am guessing you are using Mosquitto)?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mikekap/wink-mqtt-rs/issues/40#issuecomment-849862972, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEY5PIF7C43CVZROXERZLLTP2ILBANCNFSM45QXVAOQ .

froohoo commented 3 years ago

There is a log section under the mqtt broker. I only mention it because after a recent update it appears the user I had setup to publish to homeassistant had lost the necessary permissions and it was showing up in the mqtt broker logs as auth failures.

mikekap commented 3 years ago

The autodiscovery messages that are sent are definitely sent without a retain flag, but that's by design. Specifically this makes it easy to remove devices - i.e. just a restart of home assistant should do it. To rebroadcast discovery in that scenario --discovery-listen-topic is used (and it actually on by default). When home assistant first starts, it broadcasts a message on this topic and wink-mqtt-rs uses that as a signal to rebroadcast all the discovered devices.

Do you have a different discovery_prefix set in home assistant? If that's not it - how do you configure mqtt on HA? It might be that using the UI won't turn on autodiscovery correctly - https://github.com/mikekap/raspberrypi/blob/5fa549d51ee959ccf5cf7d850786c66b54590735/home-assistant/configuration.yaml#L29 is an example of how I configured my broker explicitly in the yaml file.

As for the difference in the config messages between zigbee2mqtt & wink-mqtt-rs - it doesn't look material. The one thing I would suggest is using the latest version of wink-mqtt-rs that I just pushed - it makes sure the autodiscovered entities show up as devices as well.