HomeAssistant abstraction for use with minimqtt and asyncio
MIT License
HomeAssistant abstraction for use with MQTT. Specifically aimed at using CircuitPython on microcontrollers with asyncio
and minimqtt
, but should be playable on other platforms.
Note: I really just wanted an "easy" learning IR remote, but not apparently available open-source.
The CircuitPython Client contains a static factory that creates a "wrapper" that can be used with the HA entities.
settings.toml
CIRCUITPY_WIFI_SSID="MY SSID"
CIRCUITPY_WIFI_PASSWORD="MY PASSWORD"
HAMM_BROKRE="192.168.1.4"
# default values
HAMM_BROKER_PORT = 1883 # int
HAMM_LOOP_SLEEP = 0.1 # seconds as float
HAMM_LOOP_TIMEOUT = 1.0 # seconds as float
HAMM_RECONNECT_DELAY = 5.0 # seconds as float
# if not set, will use CircuitPython defaults
# (really should be set)
HAMM_CLIENT_ID = "my_name"
utils.py
file to your CIRCUITPY
driveCIRCUITPY/code.py
Note that updating handlers/entities "states" via public methods should follow up by manually invoking the entity send_current_state
.
CommandHandler
) to interface with the other systems.I think I have the project set up correctly?
Since I come from an Object-Oriented and functional background, I originally crafted these classes in Kotlin. I ran across a situation where I could not run a JVM, so I turned to the "next easiest thing" that seemed logical and went with Python. And, since I am more familiar with and using CircuitPython, a conversion of sorts seemed pretty straight-forward.
This is where it got interesting -- I used a couple of different "AI code converters" to migrate the Kotlin code to Python. It was a decent starting point, but it is not anywhere near complete, nor does it actually capture the complexities of the Python language. (Throw in pylint
and you've got a right nightmare.)