Example #1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""

    from cozypy.client import CozytouchClient
    from cozypy.constant import DeviceType

    # Assign configuration variables. The configuration check takes care they are
    # present.
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    timeout = config.get(CONF_TIMEOUT)

    # Setup cozytouch client
    client = CozytouchClient(username, password, timeout)
    setup = client.get_setup()
    devices = []
    for heater in setup.heaters:
        for sensor in heater.sensors:
            if sensor.widget == DeviceType.TEMPERATURE:
                devices.append(CozyTouchTemperatureSensor(sensor))
            elif sensor.widget == DeviceType.ELECTRECITY:
                devices.append(CozyTouchElectricitySensor(sensor))

    _LOGGER.info("Found {count} sensors".format(count=len(devices)))
    add_devices(devices)
Example #2
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""

    from cozypy.client import CozytouchClient
    from cozypy.constant import DeviceType

    # Assign configuration variables. The configuration check takes care they are
    # present.
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    timeout = config.get(CONF_TIMEOUT)
    actuator = config.get(CONF_COZYTOUCH_ACTUATOR)

    # Setup cozytouch client
    client = CozytouchClient(username, password, timeout)
    setup = client.get_setup()
    devices = []

    for heater in setup.heaters:
        if actuator == "all":
            devices.append(CozytouchSwitch(heater))
        elif actuator == "pass" and heater.widget == DeviceType.HEATER_PASV:
            devices.append(CozytouchSwitch(heater))
        elif actuator == "i2g" and heater.widget == DeviceType.HEATER:
            devices.append(CozytouchSwitch(heater))

    _LOGGER.info("Found %d switch" % len(devices))
    add_devices(devices)
Example #3
0
    def test_setup(self):
        with patch.object(Session, 'post') as mock_post:
            mock_post.return_value = mock_response(200, {})
            client = CozytouchClient("test", "test")

            with patch.object(Session, 'get') as mock_get:
                mock_get.return_value = mock_response(200, setup_response,
                                                      True)
                setup = client.get_setup()

                self.assertIsNotNone(setup)
                self.assertEqual(len(setup.places), 1)
                self.assertEqual(len(setup.heaters), 3)
Example #4
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""

    from cozypy.client import CozytouchClient
    from cozypy.constant import DeviceType

    # Assign configuration variables. The configuration check takes care they are
    # present.
    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)
    timeout = config.get(CONF_TIMEOUT)

    # Setup cozytouch client
    client = CozytouchClient(username, password, timeout)
    setup = client.get_setup()
    devices = []
    for heater in setup.heaters:
        if heater.widget == DeviceType.HEATER:
            devices.append(StandaloneCozytouchThermostat(heater))


    _LOGGER.info("Found {count} thermostat".format(count=len(devices)))

    add_devices(devices)
Example #5
0
import os
import logging

from cozypy.client import CozytouchClient
from cozypy.exception import CozytouchException

logger = logging.getLogger("cozytouch.examples")

clientId = os.environ['COZYTOUCH_CLIENT_ID']
clientPassword = os.environ['COZYTOUCH_CLIENT_PASSWORD']

try:
    client = CozytouchClient(clientId, clientPassword)
    setup = client.get_setup()

    def print_device(device):
        print()
        print("\t Name:", device.name)
        print("\t\t Id:", device.id)
        print("\t\t Place:", device.place.name)
        print("\t\t Suported states:")
        for state in device.supported_states:
            print("\t\t\t", state)
        print("\t\t States value:")
        for state in device.supported_states:
            print("\t\t\t", state.value, device.get_state(state))
        print("\t\t Is on:", device.is_on)
        print("\t\t Operating mode:", device.operating_mode)
        if len(device.sensors) > 0:
            print("\t\t Sensors")
            for sensor in device.sensors: