Ejemplo n.º 1
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the ZoneMinder switch platform."""

    on_state = MonitorState(config.get(CONF_COMMAND_ON))
    off_state = MonitorState(config.get(CONF_COMMAND_OFF))

    switches = []
    for zm_client in hass.data[ZONEMINDER_DOMAIN].values():
        if not (monitors := zm_client.get_monitors()):
            _LOGGER.warning("Could not fetch monitors from ZoneMinder")
            return

        for monitor in monitors:
            switches.append(ZMSwitchMonitors(monitor, on_state, off_state))
Ejemplo n.º 2
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the ZoneMinder switch platform."""
    from zoneminder.monitor import MonitorState
    on_state = MonitorState(config.get(CONF_COMMAND_ON))
    off_state = MonitorState(config.get(CONF_COMMAND_OFF))

    zm_client = hass.data[ZONEMINDER_DOMAIN]

    monitors = zm_client.get_monitors()
    if not monitors:
        _LOGGER.warning('Could not fetch monitors from ZoneMinder')
        return

    switches = []
    for monitor in monitors:
        switches.append(ZMSwitchMonitors(monitor, on_state, off_state))
    add_entities(switches)
Ejemplo n.º 3
0
def setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up the ZoneMinder switch platform."""

    on_state = MonitorState(config.get(CONF_COMMAND_ON))
    off_state = MonitorState(config.get(CONF_COMMAND_OFF))

    switches = []
    for zm_client in hass.data[ZONEMINDER_DOMAIN].values():
        if not (monitors := zm_client.get_monitors()):
            _LOGGER.warning("Could not fetch monitors from ZoneMinder")
            return

        for monitor in monitors:
            switches.append(ZMSwitchMonitors(monitor, on_state, off_state))