Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event loop? #281

Open
Octelly opened this issue Dec 7, 2024 · 1 comment
Open

Event loop? #281

Octelly opened this issue Dec 7, 2024 · 1 comment

Comments

@Octelly
Copy link

Octelly commented Dec 7, 2024

Hey, I was bashing my head at this for easily like 2 hours, browsing GitHub for examples and trying to understand how this library is supposed to be used, but I just cannot figure it out.

https://github.com/OwO-Digital/nixos-config/blob/cba34d6400c61fb767e00c2624433b7c2ebd5455/packages/misc/mqtt_linux/mqtt_linux/__init__.py

I made a device with a dummy light entity using the examples provided in the README.md, but the script just runs and exits immediately. I tried supplying my own client instance, that I would manually connect to the broker and start the Paho event loop, but even that wouldn't respond to HAss' commands.

I'm new to HAss and the ecosystem around it (as well as home automation in general) and I'd like to write a simple script that would proxy local DDC/CI devices as entities, so I can view and change monitor brightness from my HAss dashboard. Surely I'm just missing something obvious 🙃.

@unixorn
Copy link
Owner

unixorn commented Dec 16, 2024

I originally wrote this as something I could call from bash scripts and create/update a MQTT entity. As such, it was originally meant to run-and-done as you're experiencing.

You need to instantiate the entity outside of your loop, then update it when the data you're using to determine its state changes. That'll automagically update the MQTT topic and HA will see the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants