Page 1 of 1

A little Home Assistant Mqtt integration using mqtt_as

Posted: Mon Feb 08, 2021 7:47 pm
by rguillon
Hi all,

I've made a little library allowing me to interface a esp32 with home assistant using Peter Hinch's mqtt_as.

I have implemented switches, basic lights, lights with brightness and RGB lights. Devices are automatically registered into home assistant with mqtt discovery, allowing to create automations.

I tried to make something easy to extend, allowing to implement other kind devices. I use it to drive the lights of my fish-tanks, I plan to add temperature sensors next.

The code quality is questionable as I'm still new to python, but it works.

https://github.com/rguillon/hatank

Re: A little Home Assistant Mqtt integration using mqtt_as

Posted: Tue Feb 09, 2021 6:09 am
by kevinkk525
That is a very nice first version!

By the way: I actually created a framework over the last few years with the exact same goal, integrating devices with home-assistant using mqtt_as with mqtt autodiscovery. It is more complex and powerful than yours, so maybe you can find some inspiration or some components you can reuse (e.g. I created climate components but have no lights, etc).
https://github.com/kevinkk525/pysmartnode

Re: A little Home Assistant Mqtt integration using mqtt_as

Posted: Tue Feb 09, 2021 7:42 pm
by rguillon
Thanks, that looks way more advanced than mine, I will definitely have a look.

Re: A little Home Assistant Mqtt integration using mqtt_as

Posted: Fri Feb 19, 2021 5:13 pm
by rguillon
I'm now using pysmartnode, thanks.

I ported my code into a new ComponentBase that was pretty easy to understand.

https://github.com/rguillon/pysmarttank

Re: A little Home Assistant Mqtt integration using mqtt_as

Posted: Fri Feb 19, 2021 7:15 pm
by kevinkk525
That code looks great!
I'm glad you found the process to implement your component easy.

I'm currently waiting for my adafruit dotstar (chinese clone) and your code is a great starting point for integrating a light component properly, which I haven't done before.