### Install and Run bosch_cli Source: https://github.com/bosch-thermostat/bosch-thermostat-client-python/blob/dev/README.md Demonstrates the installation of the bosch-thermostat-client package and how to use the included `bosch_cli` tool for interacting with Bosch thermostats. This includes setting up a virtual environment and running help commands for the CLI. ```shell # Create Python virtual environment $ python3 -m venv bosch-thermostat-client $ source bosch-thermostat-client/bin/activate # Install bosch-thermostat-client $ pip install bosch-thermostat-client # Use bosch_cli $ bosch_cli --help Usage: bosch_cli [OPTIONS] COMMAND [ARGS]... A tool to run commands against Bosch thermostat. Options: --version Show the version and exit. --help Show this message and exit. Commands: put Send value to Bosch thermostat. query Query values of Bosch thermostat. scan Create rawscan of Bosch thermostat. ``` ```shell $ bosch_cli scan --help Usage: bosch_cli scan [OPTIONS] Create rawscan of Bosch thermostat. Options: --config PATH Read configuration from PATH. [default: config.yml] --host TEXT IP address of gateway or SERIAL for XMPP [required] --token TEXT Token from sticker without dashes. [required] --password TEXT Password you set in mobile app. --protocol [XMPP|HTTP] Bosch protocol. Either XMPP or HTTP. [required] --device [NEFIT|IVT|EASYCONTROL] Bosch device type. NEFIT, IVT or EASYCONTROL. [required] -d, --debug Set Debug mode. Single debug is debug of this lib. Second d is debug of aioxmpp as well. -o, --output TEXT Path to output file of scan. Default to [raw/small]scan_uuid.json --stdout Print scan to stdout -d, --debug -i, --ignore-unknown Ignore unknown device type. Try to scan anyway. Useful for discovering new devices. -s, --smallscan [HC|DHW|SENSORS|RECORDINGS] Scan only single circuit of thermostat. --help Show this message and exit. ``` -------------------------------- ### CLI for Thermostat Query and Control Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This section provides examples of using the `bosch_cli` command-line tool for querying thermostat endpoints and performing control operations. It demonstrates how to query a single endpoint for its UUID and how to query multiple endpoints simultaneously for firmware version, current room temperature, and setpoint temperature. Authentication and connection details are specified using command-line arguments. ```bash # Query single endpoint bosch_cli query \ --host 192.168.1.100 \ --token 1234567890ABCDEF \ --password MyPassword123 \ --protocol HTTP \ --device IVT \ --path /gateway/uuid # Query multiple endpoints bosch_cli query \ --host 192.168.1.100 \ --token 1234567890ABCDEF \ --protocol HTTP \ --device IVT \ --path /gateway/versionFirmware \ --path /heatingCircuits/hc1/currentRoomTemperature \ --path /heatingCircuits/hc1/temperatureRoomSetpoint ``` -------------------------------- ### Query Gateway UUID using Configuration File (CLI) Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This example demonstrates using a YAML configuration file (`config.yml`) with the `bosch_cli` tool to avoid repeatedly typing credentials. The configuration file stores host, token, password, protocol, and device information. The `query` command is then used to retrieve the gateway's UUID. ```bash cat > config.yml < {hc.target_temperature}°C") finally: await gateway.close(force=True) asyncio.run(xmpp_connection()) ``` -------------------------------- ### Monitor Thermostat Sensors with Python Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This script shows how to read all available sensors from a Bosch thermostat system. It connects to the gateway, initializes all sensors, and then iterates through them to print their names, states, units, kinds, and device classes. Recording sensors with historical data are also identified. It uses aiohttp for async operations and the bosch_thermostat_client library. ```python import asyncio import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import HTTP, RECORDINGS from bosch_thermostat_client.const.ivt import IVT async def monitor_sensors(): async with aiohttp.ClientSession() as session: BoschGateway = bosch.gateway_chooser(device_type=IVT) gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", password="MyPassword123" ) await gateway.check_connection() # Initialize all sensors sensors = await gateway.initialize_sensors() print(f"Found {len(sensors)} sensors:") for sensor in sensors: await sensor.update() print(f" {sensor.name}: {sensor.state} {sensor.units if hasattr(sensor, 'units') else ''}") print(f" Kind: {sensor.kind}") print(f" Device class: {sensor.device_class}") # Check if sensor is a recording type if sensor.kind == RECORDINGS: print(f" Recording sensor with historical data") await gateway.close(force=True) asyncio.run(monitor_sensors()) ``` -------------------------------- ### Connect to Bosch Thermostat Gateway (Python) Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt Establishes a connection to a Bosch thermostat gateway using aiohttp and the bosch_thermostat_client library. It requires gateway host, access token, and password. The function verifies the connection, retrieves device information (UUID, name, firmware), and initializes device capabilities. It then closes the connection. ```python import asyncio import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import HTTP from bosch_thermostat_client.const.ivt import IVT async def connect_to_gateway(): async with aiohttp.ClientSession() as session: # Choose gateway type based on device BoschGateway = bosch.gateway_chooser(device_type=IVT) # Create gateway instance with credentials gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", # Token from device sticker password="MyPassword123" ) # Check connection and get UUID uuid = await gateway.check_connection() if uuid: print(f"Connected successfully! UUID: {uuid}") print(f"Device: {gateway.device_name}") print(f"Firmware: {gateway.firmware}") # Initialize all components capabilities = await gateway.get_capabilities() print(f"Capabilities: {capabilities}") await gateway.close(force=True) asyncio.run(connect_to_gateway()) ``` -------------------------------- ### Control Switches and Inputs with Python Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This script demonstrates how to access and control various switches and number inputs on a Bosch thermostat. It initializes switches, iterates through regular boolean switches, select switches (dropdowns), and number switches (numeric inputs), printing their states and available options or ranges. It relies on aiohttp for asynchronous operations and the bosch_thermostat_client library. ```python import asyncio import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import HTTP from bosch_thermostat_client.const.ivt import IVT async def manage_switches(): async with aiohttp.ClientSession() as session: BoschGateway = bosch.gateway_chooser(device_type=IVT) gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", password="MyPassword123" ) await gateway.check_connection() await gateway.initialize_switches() # Regular boolean switches switches = gateway.regular_switches print(f"Switches: {len(switches)}") for switch in switches: print(f" {switch.name}: {switch.state}") # Toggle switch if needed # await switch.turn_on() # await switch.turn_off() # Select switches (dropdowns) selects = gateway.select_switches if selects: print(f"Select controls: {len(selects)}") for select in selects: print(f" {select.name}: {select.state}") print(f" Options: {select.options}") # Number switches (numeric inputs) numbers = gateway.number_switches print(f"Number inputs: {len(numbers)}") for number in numbers: print(f" {number.name}: {number.state}") print(f" Range: {number.min_value} - {number.max_value}") await gateway.close(force=True) asyncio.run(manage_switches()) ``` -------------------------------- ### Scan Thermostat Endpoints with Python Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This Python script demonstrates how to perform comprehensive or partial scans of Bosch thermostat endpoints using the `bosch-thermostat-client` library. It requires `asyncio`, `json`, `aiohttp`, and `bosch-thermostat-client`. The script performs a full raw scan, saves it to a JSON file, and then performs smaller scans for specific circuits like heating (HC), domestic hot water (DHW), and sensors, saving each scan to a separate JSON file. ```python import asyncio import json import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import HTTP, HC, DHW, SENSORS from bosch_thermostat_client.const.ivt import IVT async def scan_device(): async with aiohttp.ClientSession() as session: BoschGateway = bosch.gateway_chooser(device_type=IVT) gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", password="MyPassword123" ) await gateway.check_connection() # Perform full raw scan of all endpoints print("Performing full rawscan...") rawscan_data = await gateway.rawscan() with open(f"rawscan_{gateway.uuid}.json", "w") as f: json.dump(rawscan_data, f, indent=4) print(f"Full scan saved to rawscan_{gateway.uuid}.json") # Perform small scan of heating circuit only print("Scanning first heating circuit...") hc_scan = await gateway.smallscan(_type=HC, circuit_number=1) with open(f"hc_scan_{gateway.uuid}.json", "w") as f: json.dump(hc_scan, f, indent=4) # Scan DHW circuit print("Scanning DHW circuit...") dhw_scan = await gateway.smallscan(_type=DHW) with open(f"dhw_scan_{gateway.uuid}.json", "w") as f: json.dump(dhw_scan, f, indent=4) # Scan sensors only print("Scanning sensors...") sensor_scan = await gateway.smallscan(_type=SENSORS) with open(f"sensor_scan_{gateway.uuid}.json", "w") as f: json.dump(sensor_scan, f, indent=4) await gateway.close(force=True) asyncio.run(scan_device()) ``` -------------------------------- ### Robust HTTP Connection and Control with Error Handling (Python) Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This Python script showcases a robust connection to a Bosch thermostat using the `bosch-thermostat-client` library over HTTP. It includes comprehensive error handling for authentication, firmware, encryption, response, and general device communication errors. The script attempts to check the connection, validate firmware, initialize heating circuits, and set the temperature, ensuring resources are closed properly in a `finally` block. ```python import asyncio import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import HTTP from bosch_thermostat_client.const.ivt import IVT from bosch_thermostat_client.exceptions import ( DeviceException, FirmwareException, EncryptionException, ResponseException, FailedAuthException ) async def robust_connection(): async with aiohttp.ClientSession() as session: BoschGateway = bosch.gateway_chooser(device_type=IVT) gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", password="MyPassword123" ) try: # Check connection uuid = await gateway.check_connection() if not uuid: print("Failed to connect to gateway") return # Validate firmware version is supported await gateway.check_firmware_validity() print(f"Firmware {gateway.firmware} is supported") # Try to initialize heating circuits await gateway.initialize_circuits("hc") hc = gateway.heating_circuits[0] await hc.update() # Attempt temperature change try: await hc.set_temperature(25.0) print("Temperature set successfully") except DeviceException as e: print(f"Failed to set temperature: {e}") except FailedAuthException: print("Authentication failed. Check token and password.") except FirmwareException as e: print(f"Unsupported firmware: {e}") except EncryptionException: print("Encryption error. Check access token.") except ResponseException as e: print(f"Invalid response from device: {e}") except DeviceException as e: print(f"Device communication error: {e}") finally: await gateway.close(force=True) asyncio.run(robust_connection()) ``` -------------------------------- ### Set Heating Temperature using CLI Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This command uses the `bosch_cli` tool to set the room setpoint temperature for the first heating circuit (hc1). It requires specifying the host, token, password, protocol, device type, and the specific path for the temperature setpoint. The desired temperature is provided as the last argument. ```bash bosch_cli put \ --host 192.168.1.100 \ --token 1234567890ABCDEF \ --password MyPassword123 \ --protocol HTTP \ --device IVT \ --path /heatingCircuits/hc1/temperatureRoomSetpoint \ 21.5 ``` -------------------------------- ### Manage Domestic Hot Water (DHW) with Python Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This script demonstrates how to monitor and control Domestic Hot Water (DHW) circuits using the Bosch Thermostat Client. It connects to the gateway, initializes DHW circuits, retrieves current and target temperatures, and allows setting new temperatures and operation modes. Requires aiohttp for asynchronous operations and the bosch_thermostat_client library. ```python import asyncio import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import DHW, HTTP from bosch_thermostat_client.const.ivt import IVT async def manage_hot_water(): async with aiohttp.ClientSession() as session: BoschGateway = bosch.gateway_chooser(device_type=IVT) gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", password="MyPassword123" ) await gateway.check_connection() # Initialize DHW circuits await gateway.initialize_circuits(DHW) dhw_circuits = gateway.dhw_circuits # Access first DHW circuit dhw = dhw_circuits[0] await dhw.update() print(f"DHW ID: {dhw.id}") print(f"Current water temp: {dhw.current_temp}°C") print(f"Target water temp: {dhw.target_temperature}°C") print(f"Operation mode: {dhw.ha_mode}") # Set water temperature to 55°C await dhw.set_temperature(55.0) # Switch to performance mode await dhw.set_operation_mode("performance") await dhw.update() print(f"Updated target: {dhw.target_temperature}°C") await gateway.close(force=True) asyncio.run(manage_hot_water()) ``` -------------------------------- ### Set DHW Temperature using CLI Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt This command uses the `bosch_cli` tool to set the domestic hot water (DHW) setpoint temperature for the first DHW circuit (dhw1). It requires specifying the host, token, protocol, device type, and the specific path for the DHW setpoint. The desired temperature is provided as the last argument. ```bash bosch_cli put \ --host 192.168.1.100 \ --token 1234567890ABCDEF \ --protocol HTTP \ --device IVT \ --path /dhwCircuits/dhw1/temperatureSetpoint \ 55 ``` -------------------------------- ### Control Bosch Heating Circuit (Python) Source: https://context7.com/bosch-thermostat/bosch-thermostat-client-python/llms.txt Manages a Bosch heating circuit, allowing users to read current and target temperatures, operation modes, and temperature limits. It supports setting new target temperatures and changing operation modes (e.g., to 'auto'). The function requires a configured gateway connection and initializes the heating circuits component. After making changes, it refreshes the circuit data to reflect the updates. ```python import asyncio import aiohttp import bosch_thermostat_client as bosch from bosch_thermostat_client.const import HC, HTTP from bosch_thermostat_client.const.ivt import IVT async def control_heating(): async with aiohttp.ClientSession() as session: BoschGateway = bosch.gateway_chooser(device_type=IVT) gateway = BoschGateway( session=session, session_type=HTTP, host="192.168.1.100", access_token="1234567890ABCDEF", password="MyPassword123" ) await gateway.check_connection() # Initialize heating circuits await gateway.initialize_circuits(HC) heating_circuits = gateway.heating_circuits # Work with first heating circuit hc = heating_circuits[0] await hc.update() print(f"Circuit ID: {hc.id}") print(f"Current temperature: {hc.current_temp}°{hc.temp_units}") print(f"Target temperature: {hc.target_temperature}°{hc.temp_units}") print(f"Operation mode: {hc.ha_mode}") print(f"Min/Max temp: {hc.min_temp}/{hc.max_temp}") # Set target temperature await hc.set_temperature(21.5) # Change operation mode to auto await hc.set_ha_mode("auto") # Refresh data after changes await hc.update() print(f"New target: {hc.target_temperature}°{hc.temp_units}") await gateway.close(force=True) asyncio.run(control_heating()) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.