Skip to content
Merged
Changes from all 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
14 changes: 11 additions & 3 deletions homeassistant/components/ness_alarm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""Support for Ness D8X/D16X devices."""
from collections import namedtuple
import datetime
import logging
from collections import namedtuple

import voluptuous as vol

from homeassistant.components.binary_sensor import DEVICE_CLASSES
from homeassistant.const import ATTR_CODE, ATTR_STATE, EVENT_HOMEASSISTANT_STOP
from homeassistant.const import (ATTR_CODE, ATTR_STATE,
EVENT_HOMEASSISTANT_STOP,
CONF_SCAN_INTERVAL)
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.dispatcher import async_dispatcher_send
Expand All @@ -25,6 +28,7 @@
CONF_ZONE_ID = 'id'
ATTR_OUTPUT_ID = 'output_id'
DEFAULT_ZONES = []
DEFAULT_SCAN_INTERVAL = datetime.timedelta(minutes=1)

SIGNAL_ZONE_CHANGED = 'ness_alarm.zone_changed'
SIGNAL_ARMING_STATE_CHANGED = 'ness_alarm.arming_state_changed'
Expand All @@ -42,6 +46,8 @@
DOMAIN: vol.Schema({
vol.Required(CONF_DEVICE_HOST): cv.string,
vol.Required(CONF_DEVICE_PORT): cv.port,
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL):
vol.All(cv.time_period, cv.positive_timedelta),
vol.Optional(CONF_ZONES, default=DEFAULT_ZONES):
vol.All(cv.ensure_list, [ZONE_SCHEMA]),
}),
Expand All @@ -67,8 +73,10 @@ async def async_setup(hass, config):
zones = conf[CONF_ZONES]
host = conf[CONF_DEVICE_HOST]
port = conf[CONF_DEVICE_PORT]
scan_interval = conf[CONF_SCAN_INTERVAL]

client = Client(host=host, port=port, loop=hass.loop)
client = Client(host=host, port=port, loop=hass.loop,
update_interval=scan_interval.total_seconds())
hass.data[DATA_NESS] = client

async def _close(event):
Expand Down