Hi fellow HA enthusiasts,
I’d like to share a small add-on I made, called API Consumer.
This add-on doesn’t do much on its own but is more of a reusable template that demonstrates how to consume any (web-)API with a custom Node.js script and post the data this API provides to the Home Assistant state machine using the internal Home Assistant API.
It’s useful when you’re trying to achieve something that hits the limits of the Home Assistant built in rest sensor platform or when an existing component/integration is not providing you all the data that you would like even though the underlying service is able to provide it. I’m for instance using it to:
- expose some Grocy add-on api endpoints that aren’t yet available in the existing custom component
- put iRail (Belgian train info) data in a sensor in a format I prefer to the existing component’s format
- consume a calDav service that isn’t compatible with the built in calDav integration
Essentially the pattern used in this add-on is another way to write a custom component. I made it because I’m more comfortable writing JavaScript than Python and because I came to the conclusion that it’s better to stuff data in the state machine than making custom cards.