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
A little Home Assistant Mqtt integration using mqtt_as
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: A little Home Assistant Mqtt integration using mqtt_as
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
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
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: A little Home Assistant Mqtt integration using mqtt_as
Thanks, that looks way more advanced than mine, I will definitely have a look.
Re: A little Home Assistant Mqtt integration using mqtt_as
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
I ported my code into a new ComponentBase that was pretty easy to understand.
https://github.com/rguillon/pysmarttank
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: A little Home Assistant Mqtt integration using mqtt_as
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.
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.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode