mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Expose ZoneMinder availability to Home Assistant (#18946)
* Expose ZoneMinder availability to Home Assistant * Bump zm-py to 0.2.0 with the availability changes published
This commit is contained in:
parent
f60f9bae00
commit
e8ec74b944
@ -44,6 +44,7 @@ class ZoneMinderCamera(MjpegCamera):
|
||||
}
|
||||
super().__init__(device_info)
|
||||
self._is_recording = None
|
||||
self._is_available = None
|
||||
self._monitor = monitor
|
||||
|
||||
@property
|
||||
@ -55,8 +56,14 @@ class ZoneMinderCamera(MjpegCamera):
|
||||
"""Update our recording state from the ZM API."""
|
||||
_LOGGER.debug("Updating camera state for monitor %i", self._monitor.id)
|
||||
self._is_recording = self._monitor.is_recording
|
||||
self._is_available = self._monitor.is_available
|
||||
|
||||
@property
|
||||
def is_recording(self):
|
||||
"""Return whether the monitor is in alarm mode."""
|
||||
return self._is_recording
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if entity is available."""
|
||||
return self._is_available
|
||||
|
@ -64,7 +64,8 @@ class ZMSensorMonitors(Entity):
|
||||
def __init__(self, monitor):
|
||||
"""Initialize monitor sensor."""
|
||||
self._monitor = monitor
|
||||
self._state = monitor.function.value
|
||||
self._state = None
|
||||
self._is_available = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@ -76,6 +77,11 @@ class ZMSensorMonitors(Entity):
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if Monitor is available."""
|
||||
return self._is_available
|
||||
|
||||
def update(self):
|
||||
"""Update the sensor."""
|
||||
state = self._monitor.function
|
||||
@ -83,6 +89,7 @@ class ZMSensorMonitors(Entity):
|
||||
self._state = None
|
||||
else:
|
||||
self._state = state.value
|
||||
self._is_available = self._monitor.is_available
|
||||
|
||||
|
||||
class ZMSensorEvents(Entity):
|
||||
@ -123,6 +130,7 @@ class ZMSensorRunState(Entity):
|
||||
def __init__(self, client):
|
||||
"""Initialize run state sensor."""
|
||||
self._state = None
|
||||
self._is_available = None
|
||||
self._client = client
|
||||
|
||||
@property
|
||||
@ -135,6 +143,12 @@ class ZMSensorRunState(Entity):
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if ZoneMinder is available."""
|
||||
return self._is_available
|
||||
|
||||
def update(self):
|
||||
"""Update the sensor."""
|
||||
self._state = self._client.get_active_state()
|
||||
self._is_available = self._client.is_available
|
||||
|
@ -15,7 +15,7 @@ import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
REQUIREMENTS = ['zm-py==0.1.0']
|
||||
REQUIREMENTS = ['zm-py==0.2.0']
|
||||
|
||||
CONF_PATH_ZMS = 'path_zms'
|
||||
|
||||
|
@ -1689,4 +1689,4 @@ zigpy-xbee==0.1.1
|
||||
zigpy==0.2.0
|
||||
|
||||
# homeassistant.components.zoneminder
|
||||
zm-py==0.1.0
|
||||
zm-py==0.2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user