Skip to content

Conversation

newtonheath
Copy link

@newtonheath newtonheath commented Jan 22, 2025

Some hackery to allow a Presto to integrate with Home Assistant.

config.py
configuration with host, token, and entity configuration

hampws.py
class to provide access to Home Assistant

hampws_light.py
demonstration of a button that reads state of a light from Home assistant - shows the state on screen as a button either yellow for on or black for off - will continue to read state and update if the light state changes outside of the Presto - will also allow the user to touch the button to turn the light off and on - huzzah!

hampws_test.py
some test code for some of the methods in the class - could do with some improvement for sure - there are some heavy logging outputs here, but for sure will help the user to learn some of the back and forth

HAMPWS (Home Assistant Micro Python Web Socket) Class, test code, and a demo of a button that can turn a light off and on as well as change state if light changes remotely
@Gadgetoid
Copy link
Member

Thank you.

Could I trouble you to move these into examples/home_assistant please? The HA specific config feels weird in the root.

@newtonheath
Copy link
Author

Here you go @Gadgetoid

@Gadgetoid
Copy link
Member

Thank you, I have a Home Assistant Green set up now, so I'll give this a try ASAP.

@Gadgetoid
Copy link
Member

I'm not sure how ASAP translated to "in two months" 💀 but here we are...

@Gadgetoid
Copy link
Member

Some feedback:

  1. After some tweaks, I got it working!
  2. Wow, it's fast.
  3. Definitely a few things broken from moving into a subfolder, we'll have to think about how best to handle that
  4. Should probably call ezwifi.connect() to set up networking somewhere.
  5. The first event I get is some weird non-sequitur with a bunch of unrelated info that parses to "OFF"

Generally, though, really awesome! This might be something that warrants its own GitHub repo with documentation and some more examples. Presto is a great light switch 😆

Graphs and charts would be awesome, too.

@newtonheath
Copy link
Author

this code is certainly flakey but I think I can get it to be more useful in a separate repo as you suggest - I'm gonna rework it as I have another related side project that will let devices like presto (such as galactic unicorn, but also regular raspi's) work with an mqtt broker and plugins kind of similarly to functionality you get with TRMNL (but just python) - I have POC of plugins (weather (POC), google calendar (POC), home assistant (TODO)) and devices (right now just test code running in a shell), but need to harden it and make it work in micropython (the rework of this code) - when I get something a little more useful I'll publish in a an open repo

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

Successfully merging this pull request may close these issues.

2 participants