Skip to content

Comments

Feature: Home Assistant#24

Open
TimBroddin wants to merge 11 commits intoPostHog:card-swappingfrom
TimBroddin:add/home-assistant
Open

Feature: Home Assistant#24
TimBroddin wants to merge 11 commits intoPostHog:card-swappingfrom
TimBroddin:add/home-assistant

Conversation

@TimBroddin
Copy link

The only reason I bought the ESP32 Feather was to be able to take pictures of my DeskHog so I can complain about the temperature in my office to my friends.

Thanks to vibe coding this is now possible. This PR:

  • Adds Home Assistant configuration to the UI.
  • Starts from the card-swapping branch, so it's easier to well ... swap cards.
  • An entity_id can be set per card, and it will render the title & value.

Coming soon (but waiting for the card configuration API to become more stable):

  • Allow a service to be called by pressing the middle button. Imagine being able to toggle your light with your DeskHog!

7FEF9CE8-24D5-41F7-B8FA-74AA0FC45C9A_1_102_o

🙇‍♂️ PostHog folks for creating such a delightful project 🙇‍♂️

ob6160 and others added 11 commits June 16, 2025 15:12
Update UK esp32-s3 supplier link
…guration options

- Increased maximum API key length for Home Assistant from 64 to 256 characters.
- Added new card type for Home Assistant entities in CardConfig and CardController.
- Implemented Home Assistant client processing in the main application loop.
- Created configuration endpoints for Home Assistant URL and API key in CaptivePortal.
- Removed example files for Home Assistant client and card due to redundancy.
- Improved logging for Home Assistant card events and updates.
- Updated HomeAssistantCard to handle entity state updates and display appropriately.
…guration options

- Increased maximum API key length for Home Assistant from 64 to 256 characters.
- Added new card type for Home Assistant entities in CardConfig and CardController.
- Implemented Home Assistant client processing in the main application loop.
- Created configuration endpoints for Home Assistant URL and API key in CaptivePortal.
- Removed example files for Home Assistant client and card due to redundancy.
- Improved logging for Home Assistant card events and updates.
- Updated HomeAssistantCard to handle entity state updates and display appropriately.
- Extend HomeAssistantParser to recognize cover entities and retrieve their position and state.
- Update HomeAssistantCard to display cover states and positions.
- Enhance documentation to include cover entity support.
@daniloc
Copy link
Collaborator

daniloc commented Jun 20, 2025

This is badass, Tim, thanks for digging into it and all your enthusiasm, you don't know how exciting it is to have you dig in like this. I use Home Assistant as well and I'm looking forward to having this.

A couple things for discussion, let me know what you think:

  • I think the numeral could do with being much bigger, similar to how we do the big number insight. We've got a juicy large font that should do the job here.
  • As I look at it, we'd now have two bespoke service configurations: PostHog and HomeAssistant. This is exactly the kinda stuff I want to enable for DeskHog, but I'd like to generalize our approach a bit. We're low on space and we'll quickly get to the point where we need to be able to compile out some stuff; decoupling a service from dedicated code for persistence would be super helpful to that goal.

Thus: what if we did an abstraction for storing service configurations? It could work kind of like cards: an enum defines the available services, and then each service has its own structure for storing whatever it needs to store. Then they could all be tucked into a services array managed by the config manager.

I can definitely get around to solving this eventually but if you wanted to take a crack at it (or ask your agent to do the same) that could scoot this PR forward a bit sooner.

@TimBroddin
Copy link
Author

This is badass, Tim, thanks for digging into it and all your enthusiasm, you don't know how exciting it is to have you dig in like this. I use Home Assistant as well and I'm looking forward to having this.

It's been wonderful hacking away at this! Finally a viable OS for microcontrollers ❤️

I think the numeral could do with being much bigger, similar to how we do the big number insight. We've got a juicy large font that should do the job here.

I agree! I haven't looked too much into the UI yet, but will keep pushing this PR forward in between other work 😀

I can definitely get around to solving this eventually but if you wanted to take a crack at it (or ask your agent to do the same) that could scoot this PR forward a bit sooner.

Let's see how far my friend Claude gets! I'll create a separate PR for this.

Is this something we'd want for the cards configs as well? Right now I have the middle button calling the toggle service for lights, toggles & covers, but I can see use cases where you'd want to configure a custom service (and maybe even payload):

CleanShot 2025-06-21 at 07 15 36@2x

Something along the lines of:

enum class ConfigFieldType {
    TEXT,
    SELECT,
    TEXTAREA,
    BOOLEAN
};

struct ConfigField {
    String key;                   
    String inputLabel;             
    String uiDescription;          
    ConfigFieldType type;          
    std::vector<String> options; 
    String defaultValue;
    bool required;
};

struct CardConfig {
    CardType id;
    std::map<String, String> config;
    int order;
};

Or do you feel like this would put too much pressure on the already scarce SRAM?

@daniloc
Copy link
Collaborator

daniloc commented Jun 21, 2025

oh man you're reading my mind. Higher extensibility for the card config values makes for more interesting abilities, and it would be great to be able to define this stuff in code and have the web UI just do the right thing without having to be edited.

I'm not too scared about memory pressure, as we do much worse with parsing insight responses from PostHog (and successfully offload to the 2MB of PSRAM for such). So yeah, if you have an immediate use case where you'll be able to test and confirm this does what you want, I say go for it!

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.

3 participants