示例#1
0
async def main():
    """
    Provide data_file.txt with ip, access_key, password and check
    if you can retrieve data from your thermostat.
    """

    async with aiohttp.ClientSession() as session:
        data_file = open("data_file_ka.txt", "r")
        data = data_file.read().splitlines()
        gateway = bosch.Gateway(session, host=data[0], access_key=data[1])
        print(await gateway.check_connection())
        print(gateway.firmware)
        print(gateway.device_name)
        await gateway.initialize_circuits(DHW)

        dhws = gateway.dhw_circuits
        dhw = dhws[0]
        await dhw.update()
        print("START1")
        print(dhw.target_temperature)
        print(dhw.current_mode)
        print(dhw.ha_mode)
        return
        # hc = hcs[1]
        # time.sleep(1)
        # await hc.update()
        # print(hc.hvac_modes)
        # print(hc.hvac_mode)
        # print(hc.target_temperature)
        await hc.set_hvac_mode("auto")
        # await hc.update()
        # print(hc.hvac_mode)
        # await hc.set_temperature(21)
        # await hc.update()
        print(hc.target_temperature)
        # print(hc.schedule.get_temp_for_date(gateway.get_info(DATE)))
        smallscan = await gateway.smallscan()
        to_file = "kamika_raw_small.json"
        with open(to_file, 'w') as logfile:
            json.dump(smallscan, logfile, indent=4)

        return
        aa = 0
        while aa < 10:
            time.sleep(1)
            await hc.update()
            print(hc.target_temperature)
            aa = aa + 1

        await hc.set_operation_mode("auto")

        aa = 0
        while aa < 10:
            time.sleep(1)
            await hc.update()
            print(hc.target_temperature)
            aa = aa + 1

        # print(gateway.get_property(TYPE_INFO, UUID))
        await session.close()
示例#2
0
async def main():
    """
    Provide data_file.txt with ip, access_key, password and check
    if you can retrieve data from your thermostat.
    """
    async with aiohttp.ClientSession() as session:
        data_file = open("data_file.txt", "r")
        data = data_file.read().splitlines()
        gateway = bosch.Gateway(session=session,
                                host=data[0],
                                access_key=data[1],
                                password=data[2])
        print(await gateway.check_connection())
        sensors = bosch_sensors(gateway.get_info(FIRMWARE_VERSION))
        print(sensors)
        await gateway.initialize_sensors(sensors)
        print(gateway.sensors)
        #
        # await gateway.rawscan()

        await session.close()
async def dhw(ctx, ip: str, token: str, password: str, debug: int,
              target_temp: int, op_mode: int, op_modes: int, setpoints: int):
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        _LOGGER.info("Debug mode active")
        _LOGGER.debug(f"Lib version is {bosch.version.__version__}")
    else:
        logging.basicConfig(level=logging.INFO)
    async with aiohttp.ClientSession() as session:
        gateway = bosch.Gateway(session=session,
                                host=ip,
                                access_key=token,
                                password=password)
        _LOGGER.debug("Trying to connect to gateway.")
        if await gateway.check_connection():
            _LOGGER.info("Successfully connected to gateway. Found UUID: %s",
                         gateway.uuid)
            await circuit_fetch(gateway, DHW, target_temp, op_mode, op_modes,
                                setpoints)
        else:
            _LOGGER.error("Couldn't connect to gateway!")
        await session.close()
async def sensors(ctx, ip: str, token: str, password: str, debug: int, sensor):
    if debug:
        logging.basicConfig(level=logging.DEBUG)
        _LOGGER.info("Debug mode active")
        _LOGGER.debug(f"Lib version is {bosch.version.__version__}")
    else:
        logging.basicConfig(level=logging.INFO)
    async with aiohttp.ClientSession() as session:
        gateway = bosch.Gateway(session=session,
                                host=ip,
                                access_key=token,
                                password=password)
        _LOGGER.debug("Trying to connect to gateway.")
        if await gateway.check_connection():
            _LOGGER.info("Successfully connected to gateway. Found UUID: %s",
                         gateway.uuid)
            sensors = gateway.initialize_sensors(list(sensor))
            for sensor_obj in sensors:
                await sensor_obj.update()
                print(sensor_obj.name, ":",
                      sensor_obj.get_property(sensor_obj.attr_id))
        else:
            _LOGGER.error("Couldn't connect to gateway!")
        await session.close()