mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +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_SWITCHES = "isy994.switches"
|
||||||
DISCOVER_SENSORS = "isy994.sensors"
|
DISCOVER_SENSORS = "isy994.sensors"
|
||||||
ISY = None
|
ISY = None
|
||||||
|
SENSOR_STRING = 'Sensor'
|
||||||
|
HIDDEN_STRING = '{HIDE ME}'
|
||||||
|
|
||||||
# setup logger
|
# setup logger
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -32,12 +34,13 @@ logger.setLevel(logging.DEBUG)
|
|||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
# pull values from configuration file
|
# check for required values in configuration file
|
||||||
if not validate_config(config,
|
if not validate_config(config,
|
||||||
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
{DOMAIN: [CONF_HOST, CONF_USERNAME, CONF_PASSWORD]},
|
||||||
logger):
|
logger):
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
|
# pull and parse standard configuration
|
||||||
user = config[DOMAIN][CONF_USERNAME]
|
user = config[DOMAIN][CONF_USERNAME]
|
||||||
password = config[DOMAIN][CONF_PASSWORD]
|
password = config[DOMAIN][CONF_PASSWORD]
|
||||||
host = urlparse(config[DOMAIN][CONF_HOST])
|
host = urlparse(config[DOMAIN][CONF_HOST])
|
||||||
@ -49,12 +52,17 @@ def setup(hass, config):
|
|||||||
addr = addr.replace('https://', '')
|
addr = addr.replace('https://', '')
|
||||||
https = True
|
https = True
|
||||||
else:
|
else:
|
||||||
logger.error('isy994 host value in configuration ' +
|
logger.error('isy994 host value in configuration file is invalid.')
|
||||||
'file is invalid.')
|
|
||||||
return False
|
return False
|
||||||
port = host.port
|
port = host.port
|
||||||
addr = addr.replace(':{}'.format(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
|
# connect to ISY controller
|
||||||
global ISY
|
global ISY
|
||||||
ISY = PyISY.ISY(addr, port, user, password, use_https=https, log=logger)
|
ISY = PyISY.ISY(addr, port, user, password, use_https=https, log=logger)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
# homeassistant imports
|
# 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.components.light import ATTR_BRIGHTNESS
|
||||||
from homeassistant.const import STATE_ON, STATE_OFF
|
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
|
# import dimmable nodes
|
||||||
for node in ISY.nodes:
|
for node in ISY.nodes:
|
||||||
if node.dimmable:
|
if node.dimmable and SENSOR_STRING not in node.name:
|
||||||
devs.append(ISYLightDevice(node))
|
devs.append(ISYLightDevice(node))
|
||||||
|
|
||||||
add_devices(devs)
|
add_devices(devs)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
# homeassistant imports
|
# 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,
|
from homeassistant.const import (STATE_OPEN, STATE_CLOSED, STATE_HOME,
|
||||||
STATE_NOT_HOME, STATE_ON, STATE_OFF)
|
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'))
|
getattr(ISY.climate, prop + '_units'))
|
||||||
devs.append(ISYSensorDevice(node))
|
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
|
# import sensor programs
|
||||||
for (folder_name, states) in (
|
for (folder_name, states) in (
|
||||||
('HA.locations', [STATE_HOME, STATE_NOT_HOME]),
|
('HA.locations', [STATE_HOME, STATE_NOT_HOME]),
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
# homeassistant imports
|
# 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
|
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.
|
# 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
|
# 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
|
# import not dimmable nodes and groups
|
||||||
for node in ISY.nodes:
|
for node in ISY.nodes:
|
||||||
if not node.dimmable:
|
if not node.dimmable and SENSOR_STRING not in node.name:
|
||||||
devs.append(ISYSwitchDevice(node))
|
devs.append(ISYSwitchDevice(node))
|
||||||
|
|
||||||
# import ISY doors programs
|
# import ISY doors programs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user