mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Implement ZoneMinder run states (#17198)
This commit is contained in:
parent
7e8973a315
commit
d7cd1a2b4b
@ -385,7 +385,7 @@ omit =
|
|||||||
homeassistant/components/zigbee.py
|
homeassistant/components/zigbee.py
|
||||||
homeassistant/components/*/zigbee.py
|
homeassistant/components/*/zigbee.py
|
||||||
|
|
||||||
homeassistant/components/zoneminder.py
|
homeassistant/components/zoneminder/*
|
||||||
homeassistant/components/*/zoneminder.py
|
homeassistant/components/*/zoneminder.py
|
||||||
|
|
||||||
homeassistant/components/tuya.py
|
homeassistant/components/tuya.py
|
||||||
|
@ -233,7 +233,7 @@ homeassistant/components/*/xiaomi_aqara.py @danielhiversen @syssi
|
|||||||
homeassistant/components/*/xiaomi_miio.py @rytilahti @syssi
|
homeassistant/components/*/xiaomi_miio.py @rytilahti @syssi
|
||||||
|
|
||||||
# Z
|
# Z
|
||||||
homeassistant/components/zoneminder.py @rohankapoorcom
|
homeassistant/components/zoneminder/ @rohankapoorcom
|
||||||
homeassistant/components/*/zoneminder.py @rohankapoorcom
|
homeassistant/components/*/zoneminder.py @rohankapoorcom
|
||||||
|
|
||||||
# Other code
|
# Other code
|
||||||
|
@ -54,6 +54,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
for sensor in config[CONF_MONITORED_CONDITIONS]:
|
for sensor in config[CONF_MONITORED_CONDITIONS]:
|
||||||
sensors.append(ZMSensorEvents(monitor, include_archived, sensor))
|
sensors.append(ZMSensorEvents(monitor, include_archived, sensor))
|
||||||
|
|
||||||
|
sensors.append(ZMSensorRunState(zm_client))
|
||||||
add_entities(sensors)
|
add_entities(sensors)
|
||||||
|
|
||||||
|
|
||||||
@ -114,3 +115,26 @@ class ZMSensorEvents(Entity):
|
|||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
self._state = self._monitor.get_events(
|
self._state = self._monitor.get_events(
|
||||||
self.time_period, self._include_archived)
|
self.time_period, self._include_archived)
|
||||||
|
|
||||||
|
|
||||||
|
class ZMSensorRunState(Entity):
|
||||||
|
"""Get the ZoneMinder run state."""
|
||||||
|
|
||||||
|
def __init__(self, client):
|
||||||
|
"""Initialize run state sensor."""
|
||||||
|
self._state = None
|
||||||
|
self._client = client
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the sensor."""
|
||||||
|
return 'Run State'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
"""Return the state of the sensor."""
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Update the sensor."""
|
||||||
|
self._state = self._client.get_active_state()
|
||||||
|
@ -10,12 +10,12 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_PASSWORD, CONF_PATH, CONF_SSL, CONF_USERNAME,
|
CONF_HOST, CONF_PASSWORD, CONF_PATH, CONF_SSL, CONF_USERNAME,
|
||||||
CONF_VERIFY_SSL)
|
CONF_VERIFY_SSL, ATTR_NAME)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REQUIREMENTS = ['zm-py==0.0.5']
|
REQUIREMENTS = ['zm-py==0.1.0']
|
||||||
|
|
||||||
CONF_PATH_ZMS = 'path_zms'
|
CONF_PATH_ZMS = 'path_zms'
|
||||||
|
|
||||||
@ -38,6 +38,11 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
})
|
})
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
SERVICE_SET_RUN_STATE = 'set_run_state'
|
||||||
|
SET_RUN_STATE_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(ATTR_NAME): cv.string
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the ZoneMinder component."""
|
"""Set up the ZoneMinder component."""
|
||||||
@ -57,4 +62,13 @@ def setup(hass, config):
|
|||||||
conf.get(CONF_PATH_ZMS),
|
conf.get(CONF_PATH_ZMS),
|
||||||
conf.get(CONF_VERIFY_SSL))
|
conf.get(CONF_VERIFY_SSL))
|
||||||
|
|
||||||
|
def set_active_state(call):
|
||||||
|
"""Set the ZoneMinder run state to the given state name."""
|
||||||
|
return hass.data[DOMAIN].set_active_state(call.data[ATTR_NAME])
|
||||||
|
|
||||||
|
hass.services.register(
|
||||||
|
DOMAIN, SERVICE_SET_RUN_STATE, set_active_state,
|
||||||
|
schema=SET_RUN_STATE_SCHEMA
|
||||||
|
)
|
||||||
|
|
||||||
return hass.data[DOMAIN].login()
|
return hass.data[DOMAIN].login()
|
6
homeassistant/components/zoneminder/services.yaml
Normal file
6
homeassistant/components/zoneminder/services.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
set_run_state:
|
||||||
|
description: Set the ZoneMinder run state
|
||||||
|
fields:
|
||||||
|
name:
|
||||||
|
description: The string name of the ZoneMinder run state to set as active.
|
||||||
|
example: 'Home'
|
@ -1594,4 +1594,4 @@ zigpy-xbee==0.1.1
|
|||||||
zigpy==0.2.0
|
zigpy==0.2.0
|
||||||
|
|
||||||
# homeassistant.components.zoneminder
|
# homeassistant.components.zoneminder
|
||||||
zm-py==0.0.5
|
zm-py==0.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user