gaetancollaud / digitalstrom-mqtt

Bridge between digitalSTROM and MQTT
GNU Affero General Public License v3.0
23 stars 4 forks source link

Implement MQTT Discovery for Home Assistant #27

Closed albertomontesg closed 2 years ago

albertomontesg commented 2 years ago

First of all I would like to thank you for this implementation between the DigitalStrom API and MQTT. This helped me to include around 25 devices into Home Assistant from the new apartment we are living in with very minimal effort.

This pull request implements the requested integration of digitalstrom-mqtt with Home Assistant by using MQTT Discovery mechanism.

This change has been requested has been openly requested in #25, and also it has been a personal request for myself considering the amount of repetition happening in my personal config.

This Pull Request implements the following:

This has been tested on my personal setup with correctly surfacing all the devices and the configuration working for all the entities (lights, covers and sensors).

MQTT Explorer:

Screenshot 2022-03-17 at 21 55 10

Home Assistant Device Registry:

Screenshot 2022-03-17 at 21 55 57
gaetancollaud commented 2 years ago

By the way, I just saw this, but would it be possible to have a toggle button also for non-dimmable lights. This look strange to me: Screenshot from 2022-03-18 09-35-05

gaetan is dimmable, invite is not

Maybe it's a home assistant feature, I don't know.

albertomontesg commented 2 years ago

The difference you observed in Home assistant between dimmable and non dimmable lights doesn't come from the discovery thing. Actually all lights are only exposed as non-dimmable one as I haven't found any way to know if the device has been configured to be dimmable or not.

Also the type of icons you see I have never seen them in Home Assistant to control a light.

albertomontesg commented 2 years ago

I have addressed all the comments as well as put the Home Assistant logic on its own file. Let me know what your think.

albertomontesg commented 2 years ago

Correction on the previous comment: I managed to extract whether a device is dimmable or not by checking the outputMode and comparing it with some value. Not able to find it in the documentation, but checking my setup, I was able to infer it.

albertomontesg commented 2 years ago

I addressed all the comments. Could you please approve to run the presubmit workflows as it is required approval for first-time contributions.

albertomontesg commented 2 years ago

Seems like the secret to run goreleaser is not present and is making fail the presubmit check.

gaetancollaud commented 2 years ago

Seems like the secret to run goreleaser is not present and is making fail the presubmit check.

It's really strange, I will have a look when I have time

gaetancollaud commented 2 years ago

Seems like the secret to run goreleaser is not present and is making fail the presubmit check.

It's really strange, I will have a look when I have time

I guess it's because you don't have the secret in your fork (maybe...). All builds pass except the releaser (with the docker login). So I will merge this and do a release.