Пример #1
0
def _setup_controller(hass, controller_config, config):
    """Set up a controller."""
    server = controller_config[CONF_HOST]
    password = controller_config[CONF_PASSWORD]
    controller = RainbirdController(server, password)
    position = len(hass.data[DATA_RAINBIRD])
    try:
        controller.get_serial_number()
    except Exception as exc:  # pylint: disable=broad-except
        _LOGGER.error("Unable to setup controller: %s", exc)
        return False
    hass.data[DATA_RAINBIRD].append(controller)
    _LOGGER.debug("Rain Bird Controller %d set to: %s", position, server)
    for platform in PLATFORMS:
        discovery.load_platform(
            hass,
            platform,
            DOMAIN,
            {
                RAINBIRD_CONTROLLER: position,
                **controller_config
            },
            config,
        )
    return True
Пример #2
0
 def test_get_serial_number(self):
     mock_response("85", serialNumber=0x12635436566)
     rainbird = RainbirdController(MOCKED_RAINBIRD_URL, MOCKED_PASSWORD)
     self.assertEqual(0x12635436566, rainbird.get_serial_number())