I am trying to make a tweak to the custom integration I’m working on, but can’t figure out how to make certain entities not visible or hidden like this…
Hello applesauce,
If you make them the diagnostic type and possibly start out as hidden, I would try that. How, I’m not sure how to do it, but as you install new integrations there are several types of entities and some are often hidden, so I know it is dome.
will look at that, thanks
Set either this attribute
self._attr_entity_registry_visible_default = False
or this property
@property
def entity_registry_visible_default(self) -> bool:
"""Return if the entity should be visible when first added."""
return False
on your sensor to make hidden when creating sensor.
Do you see a way of turning visibility on and off in the UI? I gave up on that Idea, but I also noticed you have a tutorial about creating integrations if I remember correctly? I’m pretty sure that I’m pushing the boundaries of what can be done without going with a full blown addon.
I can’t seem to easliy find a function to call to change this and as such, would have to be code to alter the registry entry for the entity.
Not fully tested but think this should do the job.
from homeassistant.helpers import entity_registry as er
......
def set_entity_visibility(hass: HomeAssistant, entity_id: str, hidden: bool):
"""Set visibility of entity id."""
entity_registry = er.async_get(hass)
if entity_registry.async_get(entity_id):
hidden_by = er.RegistryEntryHider.INTEGRATION if hidden else None
entity_registry.async_update_entity(entity_id, hidden_by=hidden_by)
# call like this
set_entity_visibility(self.hass, self.entity_id, False)
Yes that’s correct.
I’m pretty sure that I’m pushing the boundaries of what can be done without going with a full blown addon.
You’d be amazed what you can do in a custom integration. Going with an addon is really only necessary if you want to run some sort of server environment rather than an api.
Ask me some questions if you need some pointers
I keep looking for examples I can reverse engineer to see how they made things, and came to the conclusion than an integrations job was simply to add devices and entities and anything fancy is being done by automations or addons, so you’ve already encouraged me! Thanks. I will definitely test out what you gave me and follow up with more questions for sure. If anyone has examples of integrations, or custom integrations that have a multiple entity selector or more of a HA type of modern interface, that would be super helpful, or any other tutorials. Looking forward to your advanced tutorial. Your intermediate tutorial helped me finally figure out how to add a configure button, so it helped a lot!