def setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the ISY 994 platform."""
    isy_config = config.get(DOMAIN)

    user = isy_config.get(CONF_USERNAME)
    password = isy_config.get(CONF_PASSWORD)
    tls_version = isy_config.get(CONF_TLS_VER)
    host = urlparse(isy_config.get(CONF_HOST))
    port = host.port
    addr = host.geturl()
    hidden_identifier = isy_config.get(CONF_HIDDEN_STRING,
                                       DEFAULT_HIDDEN_STRING)
    sensor_identifier = isy_config.get(CONF_SENSOR_STRING,
                                       DEFAULT_SENSOR_STRING)

    global HIDDEN_STRING
    HIDDEN_STRING = hidden_identifier

    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 is invalid.')
        return False

    addr = addr.replace(':{}'.format(port), '')

    import PyISY

    global PYISY
    PYISY = PyISY

    # Connect to ISY controller.
    global ISY
    ISY = PyISY.ISY(addr,
                    port,
                    username=user,
                    password=password,
                    use_https=https,
                    tls_ver=tls_version,
                    log=_LOGGER)
    if not ISY.connected:
        return False

    _categorize_nodes(hidden_identifier, sensor_identifier)

    _categorize_programs()

    # Listen for HA stop to disconnect.
    hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop)

    # Load platforms for the devices in the ISY controller that we support.
    for component in SUPPORTED_DOMAINS:
        discovery.load_platform(hass, component, DOMAIN, {}, config)

    ISY.auto_update = True
    return True
Exemple #2
0
def setup(hass, config):
    """Setup ISY994 component.

    This will automatically import associated lights, switches, and sensors.
    """
    import PyISY

    # pylint: disable=global-statement
    # 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:
        _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 = str(config[DOMAIN].get('sensor_string', SENSOR_STRING))
    HIDDEN_STRING = str(config[DOMAIN].get('hidden_string', HIDDEN_STRING))
    tls_version = config[DOMAIN].get(CONF_TLS_VER, None)

    # Connect to ISY controller.
    global ISY
    ISY = PyISY.ISY(addr, port, user, password, use_https=https,
                    tls_ver=tls_version, log=_LOGGER)
    if not ISY.connected:
        return False

    # Listen for HA stop to disconnect.
    hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop)

    # Load components for the devices in the ISY controller that we support.
    for comp_name, discovery in ((('sensor', DISCOVER_SENSORS),
                                  ('light', DISCOVER_LIGHTS),
                                  ('switch', DISCOVER_SWITCHES))):
        component = get_component(comp_name)
        bootstrap.setup_component(hass, component.DOMAIN, config)
        hass.bus.fire(EVENT_PLATFORM_DISCOVERED,
                      {ATTR_SERVICE: discovery,
                       ATTR_DISCOVERED: {}})

    ISY.auto_update = True
    return True
Exemple #3
0
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the ISY 994 platform."""
    hass.data[isy994mrf_NODES] = {}
    for domain in SUPPORTED_DOMAINS:
        hass.data[isy994mrf_NODES][domain] = []

    hass.data[isy994mrf_WEATHER] = []

    hass.data[isy994mrf_PROGRAMS] = {}
    for domain in SUPPORTED_DOMAINS:
        hass.data[isy994mrf_PROGRAMS][domain] = []

    isy_config = config.get(DOMAIN)

    user = isy_config.get(CONF_USERNAME)
    password = isy_config.get(CONF_PASSWORD)
    tls_version = isy_config.get(CONF_TLS_VER)
    host = urlparse(isy_config.get(CONF_HOST))
    ignore_identifier = isy_config.get(CONF_IGNORE_STRING)
    sensor_identifier = isy_config.get(CONF_SENSOR_STRING)
    enable_climate = isy_config.get(CONF_ENABLE_CLIMATE)

    if host.scheme == 'http':
        https = False
        port = host.port or 80
    elif host.scheme == 'https':
        https = True
        port = host.port or 443
    else:
        _LOGGER.error("isy994mrf host value in configuration is invalid")
        return False

    import PyISY
    # Connect to ISY controller.
    isy = PyISY.ISY(host.hostname, port, username=user, password=password,
                    use_https=https, tls_ver=tls_version, log=_LOGGER)
    if not isy.connected:
        return False

    _categorize_nodes(hass, isy.nodes, ignore_identifier, sensor_identifier)
    _categorize_programs(hass, isy.programs)

    if enable_climate and isy.configuration.get('Weather Information'):
        _categorize_weather(hass, isy.climate)

    def stop(event: object) -> None:
        """Stop ISY auto updates."""
        isy.auto_update = False

    # Listen for HA stop to disconnect.
    hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop)

    # Load platforms for the devices in the ISY controller that we support.
    for component in SUPPORTED_DOMAINS:
        discovery.load_platform(hass, component, DOMAIN, {}, config)

    isy.auto_update = True
    return True
Exemple #4
0
def isy_setup():
    global isy
    SETTINGS = {}
    with open('settings/PyISY.settings.json') as data_file:    
        SETTINGS = json.load(data_file)

    isy = PyISY.ISY(SETTINGS['host'], SETTINGS['port'], SETTINGS['username'], SETTINGS['password'])
    print(isy.connected)

    isy.auto_update = True
    return isy
Exemple #5
0
 def start(self):
     LOGGER.info('Started ISY-Net NodeServer')
     self.removeNoticesAll()
     if self.check_params():
         self.isy = PyISY.ISY(self.ipaddress, '80', self.user,
                              self.password)
         if self.isy.connected:
             LOGGER.info('ISY Connected: True')
             self.isy.auto_update = True
             self.discover()
         else:
             LOGGER.info('ISY Connected: False')
 def connect(self):
     # FIXME: How to set different logger level for Events?
     self.isy = PyISY.ISY(self.isy_host, self.isy_port, self.isy_user,
                          self.isy_password, False, "1.1", LOGGER)
     self.l_info('connect', ' ISY Connected: ' + str(self.isy.connected))
     if not self.isy.connected:
         return False
     if not self.refresh():
         return False
     self.l_info('connect', 'Default config: {}'.format(hueUpnp_config))
     hueUpnp_config.devices = self.pdevices
     hueUpnp_config.logger = LOGGER
     hueUpnp_config.standard['IP'] = self.host
     hueUpnp_config.standard['PORT'] = self.port
     hueUpnp_config.standard['DEBUG'] = True
     self.hue_upnp = hue_upnp(hueUpnp_config)
     self.hue_upnp.run()
     self.listening = True
Exemple #7
0
     logfile.flush()

def refresh():
  subprocess.call(REFRESH, shell=True)
  logfile.write("Refreshing browser at {}\n".format(now))
  logfile.flush()

now = datetime.datetime.now()

os.environ['DISPLAY'] = ":0"

logfile = open(LOGFILE, "a+") 
logfile.write("Log file open: {} at {}\n".format(logfile, now))
logfile.flush()

myisy = PyISY.ISY(ADDR, PORT, USER, PASS)
logfile.write("Connected to ISY: {} at {}\n".format(myisy.connected, now))
logfile.flush()

# refresh display once a day
schedule.every().day.at(ONE_AM).do(refresh)

# Enable callbacks from ISY
myisy.auto_update = True

node = myisy.nodes[NODE]
logfile.write("Node handle obtained from ISY: {} at {}\n".format(node, now))
logfile.flush()

handler = node.status.subscribe('changed', notify)
logfile.write("Callback established to Node: {} at {}\n".format(handler, now))
if 'ifttt' in config:
    helpers.ifttt = config['ifttt']

config['isyhelper_version'] = VERSION

# Prepare the REST interface
logger.info("Configuring REST interface...")
rest = REST(config, helpers, logger)
helpers.rest = rest

info = "Starting PyISY: host=" + config['isy']['host'] + " PORT=" + str(
    config['isy']['port'])
print(info)
logger.info(info)
isy = PyISY.ISY(config['isy']['host'], config['isy']['port'],
                config['isy']['user'], config['isy']['password'], False, "1.1",
                logger)
info = " ISY Connected: " + str(isy.connected)
print(info)
logger.info(info)
isy.auto_update = True

# Now that we have the ISY setup, run all the starters
try:
    helpers.start(isy)
except ValueError as e:
    print("ERROR: Helper ISY Setup " + str(e))
    exit()

# Let the scheduler start jobs
sched.start()
Exemple #9
0
import PyISY
import json

SETTINGS = {}
with open('PyISY.settings.json') as data_file:
    SETTINGS = json.load(data_file)

isy = PyISY.ISY(SETTINGS['host'], SETTINGS['port'], SETTINGS['username'],
                SETTINGS['password'])
print(isy.connected)

isy.auto_update = True

node_names = ["ZW002_1"]


def notify(e):
    print('Notification Received')


for nn in node_names:
    node = isy.nodes[nn]
    print nn

    print node.status
    handler = node.status.subscribe('changed', notify)
Exemple #10
0
 def login(self):
     print("logging in to ISY...")
     self.isy = PyISY.ISY(self.ADDR, self.PORT, self.USER, self.PASS)
Exemple #11
0
import sys
sys.path.insert(0, '/Users/provolot/github/PyISY')
sys.path.insert(0, '/home/provolot/_GITHUB/PyISY')
import PyISY
import slackbot_settings
print(slackbot_settings.PYISY_ADDR, slackbot_settings.PYISY_PORT,
      slackbot_settings.PYISY_USER, slackbot_settings.PYISY_PASS)
client = PyISY.ISY(slackbot_settings.PYISY_ADDR, slackbot_settings.PYISY_PORT,
                   slackbot_settings.PYISY_USER, slackbot_settings.PYISY_PASS)
print(client.connected)
Exemple #12
0
import PyISY
from time import sleep
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)

logger.debug('test')

# connect to ISY
isy = PyISY.ISY('192.168.1.213',
                443,
                'admin',
                'admin',
                use_https=True,
                log=logger)
print(isy.connected)


def change_event_handler(event):
    print('Change Event {}'.format(event))


def control_event_handler(event):
    print('Control Event {}'.format(event))


#NODE = '49 A2 BE 1'
NODE = '42 C8 99 1'