Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ omit =
homeassistant/components/*/zigbee.py

homeassistant/components/zoneminder/*
homeassistant/components/*/zoneminder.py

homeassistant/components/tuya.py
homeassistant/components/*/tuya.py
Expand Down
3 changes: 1 addition & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ homeassistant/components/*/xiaomi_aqara.py @danielhiversen @syssi
homeassistant/components/*/xiaomi_miio.py @rytilahti @syssi

# Z
homeassistant/components/zoneminder/ @rohankapoorcom
homeassistant/components/*/zoneminder.py @rohankapoorcom
homeassistant/components/zoneminder/* @rohankapoorcom

# Other code
homeassistant/scripts/check_config.py @kellerza
5 changes: 5 additions & 0 deletions homeassistant/components/zoneminder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from homeassistant.const import (
CONF_HOST, CONF_PASSWORD, CONF_PATH, CONF_SSL, CONF_USERNAME,
CONF_VERIFY_SSL, ATTR_NAME, ATTR_ID)
from homeassistant.helpers.discovery import async_load_platform

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -93,4 +94,8 @@ def set_active_state(call):
schema=SET_RUN_STATE_SCHEMA
)

hass.async_create_task(
async_load_platform(hass, 'binary_sensor', DOMAIN, {}, config)
)

return success
47 changes: 47 additions & 0 deletions homeassistant/components/zoneminder/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Support for ZoneMinder Binary Sensor.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.zoneminder/
"""
from homeassistant.components.binary_sensor import BinarySensorDevice

from homeassistant.components.zoneminder import DOMAIN as ZONEMINDER_DOMAIN

DEPENDENCIES = ['zoneminder']


async def async_setup_platform(hass, config, add_entities, discovery_info=None):
Comment thread
rohankapoorcom marked this conversation as resolved.
Outdated
"""Set up the ZoneMinder binary sensor platform."""

sensors = []
for host_name, zm_client in hass.data[ZONEMINDER_DOMAIN].items():
sensors.append(ZMAvailabilitySensor(host_name, zm_client))
add_entities(sensors)
return True


class ZMAvailabilitySensor(BinarySensorDevice):
"""Representation of the availability of ZoneMinder as a binary sensor."""

def __init__(self, host_name, client):
"""Initialize availability sensor."""
self._state = None
self._name = host_name
self._client = client

@property
def name(self):
return self._name

@property
def is_on(self):
return self._state

@property
def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return 'connectivity'

def update(self):
self._state = self._client.is_available