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:
1 parent
fe93ea9bdf
commit
bc30491dc0
4 files changed
+78
-54
No files matched your search
@@ -29,16 +29,15 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
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))
|
||||
for zm_client in hass.data[ZONEMINDER_DOMAIN].values():
|
||||
monitors = zm_client.get_monitors()
|
||||
if not monitors:
|
||||
_LOGGER.warning('Could not fetch monitors from ZoneMinder')
|
||||
return
|
||||
|
||||
for monitor in monitors:
|
||||
switches.append(ZMSwitchMonitors(monitor, on_state, off_state))
|
||||
add_entities(switches)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user