1 """Support for Home Assistant Cloud binary sensors."""
3 from __future__
import annotations
8 from hass_nabucasa
import Cloud
11 BinarySensorDeviceClass,
20 from .client
import CloudClient
21 from .const
import DATA_CLOUD, DISPATCHER_REMOTE_UPDATE
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up the Home Assistant Cloud binary sensors."""
32 cloud = hass.data[DATA_CLOUD]
37 """Representation of an Cloud Remote UI Connection binary sensor."""
39 _attr_name =
"Remote UI"
40 _attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
41 _attr_should_poll =
False
42 _attr_unique_id =
"cloud-remote-ui-connectivity"
43 _attr_entity_category = EntityCategory.DIAGNOSTIC
45 def __init__(self, cloud: Cloud[CloudClient]) ->
None:
46 """Initialize the binary sensor."""
51 """Return true if the binary sensor is on."""
52 return self.
cloudcloud.remote.is_connected
56 """Return True if entity is available."""
57 return self.
cloudcloud.remote.certificate
is not None
60 """Register update dispatcher."""
62 async
def async_state_update(data: Any) ->
None:
63 """Update callback."""
64 await asyncio.sleep(WAIT_UNTIL_CHANGE)
69 self.
hasshass, DISPATCHER_REMOTE_UPDATE, async_state_update
None async_added_to_hass(self)
None __init__(self, Cloud[CloudClient] cloud)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)