Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
940 B
Python
Raw Permalink Normal View History

"""Support for monitoring the state of UpCloud servers."""
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
2021-05-15 07:49:41 +03:00
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from .coordinator import UpCloudConfigEntry
from .entity import UpCloudServerEntity
2021-05-15 07:49:41 +03:00
async def async_setup_entry(
hass: HomeAssistant,
config_entry: UpCloudConfigEntry,
async_add_entities: AddConfigEntryEntitiesCallback,
2021-05-15 07:49:41 +03:00
) -> None:
"""Set up the UpCloud server binary sensor."""
coordinator = config_entry.runtime_data
entities = [UpCloudBinarySensor(config_entry, uuid) for uuid in coordinator.data]
async_add_entities(entities, True)
class UpCloudBinarySensor(UpCloudServerEntity, BinarySensorEntity):
"""Representation of an UpCloud server sensor."""
_attr_device_class = BinarySensorDeviceClass.POWER