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(StandaloneCozytouchThermostat(heater)) elif actuator == "pass" and heater.widget == DeviceType.HEATER_PASV: devices.append(StandaloneCozytouchThermostat(heater)) elif actuator == "i2g" and heater.widget == DeviceType.HEATER: devices.append(StandaloneCozytouchThermostat(heater)) _LOGGER.info("Found %d thermostat" % len(devices)) add_devices(devices)
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 [ sensor for sensor in heater.sensors if sensor.widget == DeviceType.OCCUPANCY ]: devices.append(CozytouchOccupancySensor(sensor)) _LOGGER.info("Found %d binary sensor" % len(devices)) add_devices(devices)
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 %d switch" % len(devices)) add_devices(devices)
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)
import os import logging import time from cozypy.client import CozytouchClient from cozypy.constant import DeviceCommand from cozypy.exception import CozytouchException from cozypy.objects import CozytouchHeater logger = logging.getLogger("cozytouch.examples") clientId = os.environ['COZYTOUTCH_CLIENT_ID'] clientPassword = os.environ['COZYTOUTCH_CLIENT_PASSWORD'] try: client = CozytouchClient(clientId, clientPassword) heater = CozytouchHeater({ "deviceURL": "io://0812-9894-4518/10071767#1", "states": [{ 'name': 'core:NameState', 'type': 3, 'value': 'I2G_Actuator' }, { 'name': 'core:VersionState', 'type': 3, 'value': '48373431303038202020' }, { 'name': 'core:PriorityLockTimerState', 'type': 1, 'value': 0
import os import logging from cozypy.client import CozytouchClient from cozypy.exception import CozytouchException from cozypy.objects import CozytouchHeater from cozypy.constant import OperatingModeState logging.config.fileConfig('logging.conf') logger = logging.getLogger("cozytouch.examples") clientId = os.environ['COZYTOUTCH_CLIENT_ID'] clientPassword = os.environ['COZYTOUTCH_CLIENT_PASSWORD'] try: client = CozytouchClient(clientId, clientPassword) devices = client.get_devices() states = client.get_device_info("io://0812-9894-4518/10071767#1") for state in states: print("\t\t", state["name"], state["value"]) heater = CozytouchHeater({ "deviceURL": "io://0812-9894-4518/10071767#1", "states": states }) heater.client = client heater.set_eco_temperature(16) heater.set_comfort_temperature(18) heater.set_operating_mode(OperatingModeState.INTERNAL) heater.update()
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: