Add support for connecting to multiple zoneminder instances (#19955)
* Add support for connecting to multiple zoneminder instances * Lint * Lint * Clean up and better error handling * Fix config validation * Lint
This commit is contained in:
parent
fe93ea9bdf
commit
bc30491dc0
4 changed files with 78 additions and 54 deletions
|
@ -42,19 +42,21 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
"""Set up the ZoneMinder sensor platform."""
|
||||
include_archived = config.get(CONF_INCLUDE_ARCHIVED)
|
||||
|
||||
zm_client = hass.data[ZONEMINDER_DOMAIN]
|
||||
monitors = zm_client.get_monitors()
|
||||
if not monitors:
|
||||
_LOGGER.warning('Could not fetch any monitors from ZoneMinder')
|
||||
|
||||
sensors = []
|
||||
for monitor in monitors:
|
||||
sensors.append(ZMSensorMonitors(monitor))
|
||||
for zm_client in hass.data[ZONEMINDER_DOMAIN].values():
|
||||
monitors = zm_client.get_monitors()
|
||||
if not monitors:
|
||||
_LOGGER.warning('Could not fetch any monitors from ZoneMinder')
|
||||
|
||||
for sensor in config[CONF_MONITORED_CONDITIONS]:
|
||||
sensors.append(ZMSensorEvents(monitor, include_archived, sensor))
|
||||
for monitor in monitors:
|
||||
sensors.append(ZMSensorMonitors(monitor))
|
||||
|
||||
sensors.append(ZMSensorRunState(zm_client))
|
||||
for sensor in config[CONF_MONITORED_CONDITIONS]:
|
||||
sensors.append(
|
||||
ZMSensorEvents(monitor, include_archived, sensor)
|
||||
)
|
||||
|
||||
sensors.append(ZMSensorRunState(zm_client))
|
||||
add_entities(sensors)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue