#Virtual HA Dashboard
1 messages · Page 1 of 1 (latest)
First part registers a callback
Second part calls it to actually add it (in this case a lock, but it works the same for binary sensors)
Tedee actually has binary sensors… totally forgot
For the virtual devices
Maybe i'd just add them as Ha device
And set via_device to mark to which session/glasses they belong
Oh, okay, so you are using the callback to keep having access to the async_add_entites method. Is there no way to call this function directly from the HASS object?
No, also you don’t want to create arbitrary entities, but your entities, with your specifications
But I suggest you add a coordinator anyways, to have a proper place to do the websocket connection and callbacks
Could work with the HASS object that is being supplied scoped to your integration only but maybe there was a reason for the way it currently is.
Do you know the reason why async_add_entities is nested into a function itself and not passed to the coordinatior directly?
Also, how would I remove an entity as I don't see a async_remove_entities function anywhere.
removing an entity can be done by either removing the device it belongs to (that's what tedee) does or calling async_remove on the entity_registry https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/entity_registry.py#L899
because in that case I want to control the message signature
like in that case, I first fetch something from the coordinator based on lock_id
Oh. but couldn't I call https://github.com/home-assistant/core/blob/f18ddb628c3574bc82e21563d9ba901bd75bc8b5/homeassistant/helpers/entity_registry.py#L774 to also create the entities whenever I want?
not sure tbh, but I don't think I've seen that outside of tests
for example, I don't know how those entities determine their state
that's what I meant earlier when I said you want entities from your class. Like you want a AreaBinarySensor that knows where to look for it's state based on it's id or something
Oh okay yep, the params of the method seem a bit more complex than just passing a Instance of a Class into the function. Then I'll use the proper method. Thanks for the help, it's greatly appreciated! ❤️