Seems like this can only be done in the UI.
This would be useful for Integrations that connect to Devices/Services that are not always running.
I would love to use this for OctoPrint, which (in my case) only runs occasionally. For Example a Ping Sensor could check if the Device is up an then enable the Integration. After the print is done and the printer cooled down I want to shut down OctoPrint and disable the Integration again.
Currently the OctoPrint Integration is always active which slows down every restart of Home Assistant and adds unnecessary Warnings to the Log.
When I’m away on holiday, I use a smart plug to turn off devices I won’t need whilst I’m away but on standby especially WiFi connected devices such as Elgato Key Lights, Logitech Harmony Hub, etc to save on energy cost. When that happens, Home Assistant rightly reports errors because it’s unable to connect to them so disabling these would be a way to stop the errors.
If xyz == unkown / unavailable => reload integration that provides xyz
I just had such a case recently, when a communication issue caused the entities to become unavailable - and I had to reload the integration in order to reconnect the integration to the “datasource”
You can already use the service homeassistant.reload_config_entry to reload an integration. I’ve a few button cards using Call Service to do this and works well…
I like your use cases. I have one as well. There’s a smart plug behind both of my TVs, I turn it off when that room isn’t in use to save energy. When I do this the Roku and Vizio both lose power and HA cannot reach them, causing errors.
That being said, I don’t agree with the solution here. I don’t actually want to disable this integration as that disables all the entities which creates all new errors. Since any automation or dashboard that references them fails to find them.
I think what would work better is a way to set availability for any device or integration, like you can for a template entity. Then you could say the integration/device is only available when the outlet is on, or the ping sensor finds the octoprint device, or someone is home, etc. All the entities and devices would still exist in these cases they would simply becomes unavailable when their availability condition is false and then work as normal otherwise.