mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Added hidden_string and sensor_string properties to the isy994 configuration to allow nodes to be hidden and to be handled as sensors. Implimented the sensor_string. Any node name that contains the sensor_string in its name will be treated as a sensor instead of a switch or light. The hidden_string will be implimented later.
This commit is contained in:
parent
0e9a8a7cc2
commit
83aea10f06
@ -25,6 +25,8 @@ DISCOVER_LIGHTS = "isy994.lights"
|
||||
DISCOVER_SWITCHES = "isy994.switches"
|
||||
DISCOVER_SENSORS = "isy994.sensors"
|
||||
ISY = None
|
||||
SENSOR_STRING = 'Sensor'
|
||||
HIDDEN_STRING = '{HIDE ME}'
|
||||
|
||||
# setup logger
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -32,28 +34,34 @@ logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
# pull values from configuration file
|
||||
# check for required values in configuration file
|
||||
if not validate_config(config,
|
||||
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
||||
logger):
|
||||
return False
|
||||
|
||||
# pull and parse standard configuration
|
||||
user = config[DOMAIN][CONF_USERNAME]
|
||||
password = config[DOMAIN][CONF_PASSWORD]
|
||||
host = urlparse(config[DOMAIN][CONF_HOST])
|
||||
addr = host.geturl()
|
||||
if host.scheme == 'http':
|
||||
addr = addr.replace('http://', '')
|
||||
https = False
|
||||
elif host.scheme == 'https':
|
||||
addr = addr.replace('https://', '')
|
||||
https = True
|
||||
else:
|
||||
user = config[DOMAIN][CONF_USERNAME]
|
||||
password = config[DOMAIN][CONF_PASSWORD]
|
||||
host = urlparse(config[DOMAIN][CONF_HOST])
|
||||
addr = host.geturl()
|
||||
if host.scheme == 'http':
|
||||
addr = addr.replace('http://', '')
|
||||
https = False
|
||||
elif host.scheme == 'https':
|
||||
addr = addr.replace('https://', '')
|
||||
https = True
|
||||
else:
|
||||
logger.error('isy994 host value in configuration ' +
|
||||
'file is invalid.')
|
||||
return False
|
||||
port = host.port
|
||||
addr = addr.replace(':{}'.format(port), '')
|
||||
logger.error('isy994 host value in configuration file is invalid.')
|
||||
return False
|
||||
port = host.port
|
||||
addr = addr.replace(':{}'.format(port), '')
|
||||
|
||||
# pull and parse optional configuration
|
||||
global SENSOR_STRING
|
||||
global HIDDEN_STRING
|
||||
SENSOR_STRING = config[DOMAIN].get('sensor_string', SENSOR_STRING)
|
||||
HIDDEN_STRING = config[DOMAIN].get('hidden_string', HIDDEN_STRING)
|
||||
|
||||
# connect to ISY controller
|
||||
global ISY
|
||||
|
@ -3,7 +3,7 @@
|
||||
import logging
|
||||
|
||||
# homeassistant imports
|
||||
from homeassistant.components.isy994 import ISYDeviceABC, ISY
|
||||
from homeassistant.components.isy994 import ISYDeviceABC, ISY, SENSOR_STRING
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS
|
||||
from homeassistant.const import STATE_ON, STATE_OFF
|
||||
|
||||
@ -19,7 +19,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
# import dimmable nodes
|
||||
for node in ISY.nodes:
|
||||
if node.dimmable:
|
||||
if node.dimmable and SENSOR_STRING not in node.name:
|
||||
devs.append(ISYLightDevice(node))
|
||||
|
||||
add_devices(devs)
|
||||
|
@ -3,7 +3,7 @@
|
||||
import logging
|
||||
|
||||
# homeassistant imports
|
||||
from homeassistant.components.isy994 import ISY, ISYDeviceABC
|
||||
from homeassistant.components.isy994 import ISY, ISYDeviceABC, SENSOR_STRING
|
||||
from homeassistant.const import (STATE_OPEN, STATE_CLOSED, STATE_HOME,
|
||||
STATE_NOT_HOME, STATE_ON, STATE_OFF)
|
||||
|
||||
@ -26,6 +26,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
getattr(ISY.climate, prop + '_units'))
|
||||
devs.append(ISYSensorDevice(node))
|
||||
|
||||
# import sensor nodes
|
||||
for node in ISY.nodes:
|
||||
if SENSOR_STRING in node.name:
|
||||
devs.append(ISYSensorDevice(node, [STATE_ON, STATE_OFF]))
|
||||
|
||||
# import sensor programs
|
||||
for (folder_name, states) in (
|
||||
('HA.locations', [STATE_HOME, STATE_NOT_HOME]),
|
||||
|
@ -3,7 +3,7 @@
|
||||
import logging
|
||||
|
||||
# homeassistant imports
|
||||
from homeassistant.components.isy994 import ISY, ISYDeviceABC
|
||||
from homeassistant.components.isy994 import ISY, ISYDeviceABC, SENSOR_STRING
|
||||
from homeassistant.const import STATE_ON, STATE_OFF # STATE_OPEN, STATE_CLOSED
|
||||
# The frontend doesn't seem to fully support the open and closed states yet.
|
||||
# Once it does, the HA.doors programs should report open and closed instead of
|
||||
@ -21,7 +21,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
# import not dimmable nodes and groups
|
||||
for node in ISY.nodes:
|
||||
if not node.dimmable:
|
||||
if not node.dimmable and SENSOR_STRING not in node.name:
|
||||
devs.append(ISYSwitchDevice(node))
|
||||
|
||||
# import ISY doors programs
|
||||
|
Loading…
x
Reference in New Issue
Block a user