Need some advice for a device I'm building

Hello people,

I’m using Home Assistant for quite a few years and I’m a software dev so I’m really fond of the way the project is structured, from frontend to backend. I just hoped someone would have time for me to give me some good advice!

My situation is as follows, Home Assistant is a perfect central hub for controlling everything, when I’m in lovelace i can do whatever i want. That’s great and all but i am currently working on a project and i fear it can’t be done.

I won’t go to deep into the thing I’m building but basically it’s a device with a 3d printed enclosure. It has a e-ink display en just a macropad which lights up relevant buttons for the current context. Because I’m using PaperTTY i can only run console applications but that isn’t a problem, with Spectre.Console i can create graphs, tables, everything you need.

The only thing i struggle with is communicating with the backend. I could access the Home Assistant database, get all entities in the room the device is currently in, use the lovelace way to do the API requests but that just doesn’t sit right with me.

Does anyone know a good way to communicate to the backend. Maybe i can follow the javascript implementation of how lovelace opens a websocket, implement something that allows me to create the right requests dynamically and update changes on my side.

Thank you for reading this! If you think my idea is stupid to begin with i can eleborate further but this post is so long already, also this is my first post here because most of my problems were solved by you lovely people while i was lurking. Please correct me if my tags are incorrect, or my question is asked in the wrong way, constructive critism is good!

TDLR; how to create my own frontend application that works as smoothly and consistent as lovelace without hardcoding or accessing the homeassistant database through a direct connection instead of talking to the backend.

HA has a javascript library available to use in projects for connecting to HA, getting entities, config, etc, and managing the communication back and forth: GitHub - home-assistant/home-assistant-js-websocket: JavaScript websocket client for Home Assistant

Oh my god thank you so much! Not a huge javascript fan so I’m going to build a JS app for other projects that need this kind of communication.