homeassistant-config/custom_components/lirc_network/binary_sensor.py

16 lines
507 B
Python
Raw Normal View History

2020-04-19 16:00:50 +02:00
import logging
from ..reconnecting_client import IsConnectedSensor
from . import DATA_LIRC_NETWORK
_LOGGER = logging.getLogger(__name__)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
connections = hass.data[DATA_LIRC_NETWORK]
sensors = []
for connection in connections:
sensor = IsConnectedSensor(connection.get_name() + "_connected")
connection.connected_sensor = sensor
sensors.append(sensor)
async_add_entities(sensors)