mirror of
https://github.com/home-assistant/core.git
synced 2025-06-08 15:17:07 +00:00

* implement config flow * add tests * fix hassfest and requirements * abort import on connection error * add add_suggested_values_to_schema * mock async_setup_entry * revert code owner change * fix try connect in config flow * add device info * allow multiple instances * fix import in config flow * remove custom scan interval from coordinator * applay suggestions * apply suggestions * take over ownership from @meichthys * cleanup import data before passing to user step * apply suggestions to tests * add untested files to .coveragerc
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Summary binary data from Nextcoud."""
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import NextcloudDataUpdateCoordinator
|
|
from .entity import NextcloudEntity
|
|
|
|
BINARY_SENSORS = (
|
|
"nextcloud_system_enable_avatars",
|
|
"nextcloud_system_enable_previews",
|
|
"nextcloud_system_filelocking.enabled",
|
|
"nextcloud_system_debug",
|
|
)
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
|
) -> None:
|
|
"""Set up the Nextcloud binary sensors."""
|
|
coordinator: NextcloudDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
|
async_add_entities(
|
|
[
|
|
NextcloudBinarySensor(coordinator, name)
|
|
for name in coordinator.data
|
|
if name in BINARY_SENSORS
|
|
]
|
|
)
|
|
|
|
|
|
class NextcloudBinarySensor(NextcloudEntity, BinarySensorEntity):
|
|
"""Represents a Nextcloud binary sensor."""
|
|
|
|
@property
|
|
def is_on(self) -> bool:
|
|
"""Return true if the binary sensor is on."""
|
|
return self.coordinator.data.get(self.item) == "yes"
|