### Install and Use Pre-commit Hooks Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Install pre-commit to automatically check code quality before each commit. Run pre-commit on all files for initial setup. ```bash pip install pre-commit ``` ```bash pre-commit install ``` ```bash pre-commit run --all-files ``` -------------------------------- ### Set Up Virtual Environment and Install Dependencies Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Create and activate a virtual environment, then install the package in development mode and its testing dependencies. ```bash python -m venv venv source venv/bin/activate # On Linux/macOS # or virtualenv\Scripts\activate # On Windows ``` ```bash pip install -e . ``` ```bash pip install -r requirements-test.txt pip install ruff pylint ``` -------------------------------- ### PyDaikin CLI Examples Source: https://context7.com/fredrike/pydaikin/llms.txt Command-line examples for connecting to a Daikin device, tailing sensor data, logging to CSV, and increasing verbosity. ```bash pydaikin 192.168.1.44 --password skyfi_pass --mode cool ``` ```bash pydaikin 192.168.1.42 --sensor ``` ```bash pydaikin 192.168.1.42 --sensor --file /tmp/daikin_log.csv ``` ```bash pydaikin 192.168.1.42 -vvv ``` -------------------------------- ### Home Assistant SSH Add-on Configuration Example Source: https://github.com/fredrike/pydaikin/wiki/Debugging-from-hassio Example configuration for the Home Assistant SSH add-on, specifying username and password for login. ```yaml username: home password: swaddling-spooky-princess ``` -------------------------------- ### PyDaikin CLI Examples Source: https://context7.com/fredrike/pydaikin/llms.txt Control and monitor Daikin devices directly from the command line using the `pydaikin` utility. Supports listing devices, showing status, and setting various parameters. ```bash # List all devices discovered on the LAN pydaikin --list # Show summary values for a device pydaikin 192.168.1.42 # Show all values pydaikin 192.168.1.42 --all # Set mode to cool, target temperature to 22°C pydaikin 192.168.1.42 --mode cool --temp 22 # Set fan speed and direction pydaikin 192.168.1.42 --fan auto --direction vertical # Enable away mode pydaikin 192.168.1.42 --away on # BRP072Cxx device (key required) pydaikin 192.168.1.43 --key MY_SECRET_KEY --mode cool --temp 21 ``` -------------------------------- ### Install pydaikin from GitHub in Home Assistant Source: https://github.com/fredrike/pydaikin/wiki/Debugging-from-hassio Use this command within the SSH add-on to install or update the pydaikin library from a specific Git branch. Ensure protection mode is disabled in the add-on configuration. ```sh docker exec -it homeassistant pip install --force --no-deps git+https://github.com/fredrike/pydaikin.git@master ``` -------------------------------- ### Install pydaikin from GitHub in Hass.io Source: https://github.com/fredrike/pydaikin/wiki/Debugging-from-hassio Use this command to install a specific Python package directly from a Git repository into your Hass.io environment. This is useful for installing development versions or custom forks. ```bash docker exec -it homeassistant pip install --no-deps --force git+https://github.com/fredrike/pydaikin.git@master ``` -------------------------------- ### Example Async Test Structure with Pytest Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Demonstrates the structure for writing asynchronous tests using pytest and pytest-asyncio. It includes arranging the test environment, acting by calling a device method, and asserting the expected outcome. ```python import pytest from pydaikin.daikin_base import Appliance @pytest.mark.asyncio async def test_your_feature(): """Test description of what this test validates.""" # Arrange device = Appliance("192.168.1.1") # Act result = await device.your_method() # Assert assert result == expected_value ``` -------------------------------- ### Manage Appliance Status with ApplianceValues Source: https://context7.com/fredrike/pydaikin/llms.txt ApplianceValues is a MutableMapping that tracks HTTP resource origins for values and invalidates TTLs upon reading. Use get(invalidate=False) to read without marking the resource stale. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: # Direct dict-style access print(device.values["mode"]) # marks resource as needing refresh # get() with invalidate=False — read without marking resource stale mode = device.values.get("mode", invalidate=False) print(mode) # Check whether a resource needs to be fetched needs_update = device.values.should_resource_be_updated("aircon/get_sensor_info") print(needs_update) # True / False # Manually force a resource to be refetched next cycle device.values.invalidate_resource("aircon/get_sensor_info") # update_by_resource records which resource owns each key device.values.update_by_resource( "aircon/get_sensor_info", {"htemp": "23.0", "otemp": "35.0"} ) print(device.values["htemp"]) # "23.0" asyncio.run(main()) ``` -------------------------------- ### Initialize and Use DaikinBRP084 with Factory Source: https://context7.com/fredrike/pydaikin/llms.txt Demonstrates how the `DaikinFactory` automatically detects firmware 2.8.0 and returns a `DaikinBRP084` instance. Shows how to update status, access device properties, and perform basic control operations. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): # Factory auto-detects firmware 2.8.0 and returns DaikinBRP084 async with await DaikinFactory("192.168.1.50") as device: from pydaikin.daikin_brp084 import DaikinBRP084 assert isinstance(device, DaikinBRP084) await device.update_status() print(f"Mode: {device['mode']}") # e.g. 'cool' print(f"Inside: {device.inside_temperature}°C") print(f"Outside: {device.outside_temperature}°C") print(f"Humidity:{device['hhum']}%") # Temperature conversion helpers print(DaikinBRP084.hex_to_temp("2C")) # 22.0 (0x2C = 44 / 2) print(DaikinBRP084.temp_to_hex(22.0)) # '2c' # Control (same API as other classes) await device.set({"mode": "cool", "stemp": "22", "f_rate": "auto"}) await device.set({"mode": "off"}) # Swing states: 'off', 'vertical', 'horizontal', 'both' await device.set({"f_dir": "both"}) asyncio.run(main()) ``` -------------------------------- ### DaikinFactory - Auto-detect and connect to a device Source: https://context7.com/fredrike/pydaikin/llms.txt The `DaikinFactory` async factory function is the primary entry point for connecting to a Daikin device. It probes the device's IP address, automatically detects the correct implementation class, and returns a fully initialized `Appliance` instance. It supports optional `key` for BRP072C devices and `password` for SkyFi devices, and can utilize a shared `aiohttp.ClientSession`. ```APIDOC ## DaikinFactory — auto-detect and connect to a device `DaikinFactory` is an async factory that probes a given IP address (or hostname) and returns the correct `Appliance` subclass. It tries BRP084 (firmware 2.8.0), then BRP069, then AirBase in order, raising `DaikinException` if none succeed. Supports optional `key` (BRP072C) and `password` (SkyFi) arguments. ```python import asyncio import aiohttp from pydaikin.factory import DaikinFactory from pydaikin.exceptions import DaikinException async def main(): # Standard BRP069/BRP072A device — auto-detected async with await DaikinFactory("192.168.1.42") as device: print(type(device).__name__) # e.g. DaikinBRP069 print(device.inside_temperature) # e.g. 22.0 print(device.outside_temperature) # e.g. 34.5 print(device.target_temperature) # e.g. 24.0 device.show_values() # print all key/value pairs # BRP072Cxx (HTTPS + auth key) async with await DaikinFactory("192.168.1.43", key="MY_SECRET_KEY") as device: await device.update_status() print(device["mode"]) # e.g. 'cool' # SkyFi device (password required) async with await DaikinFactory("192.168.1.44", password="skyfi_pass") as device: await device.update_status() print(device.inside_temperature) # Shared aiohttp session async with aiohttp.ClientSession() as session: try: device = await DaikinFactory("192.168.1.42", session=session) await device.update_status() device.show_sensors() except DaikinException as exc: print(f"Connection failed: {exc}") asyncio.run(main()) ``` ``` -------------------------------- ### Configure pydaikin Logging in configuration.yaml Source: https://github.com/fredrike/pydaikin/wiki/Increase-logging-level Set the default and specific log levels for components in your Home Assistant configuration.yaml file. Use 'notset' to inherit the default level or specify a level like 'debug' or 'warning'. ```yaml logger: default: warning logs: homeassistant.components.mqtt: warning # log level for the `aiohttp` Python package aiohttp: debug # log level for the `pydaikin` Python package pydaikin: notset ``` -------------------------------- ### DaikinFactory: Auto-detect and Connect to a Device Source: https://context7.com/fredrike/pydaikin/llms.txt Use DaikinFactory as the primary entry point to probe a device's IP address and return the correct Appliance subclass. It supports optional key and password arguments for specific device types and can utilize a shared aiohttp session. ```python import asyncio import aiohttp from pydaikin.factory import DaikinFactory from pydaikin.exceptions import DaikinException async def main(): # Standard BRP069/BRP072A device — auto-detected async with await DaikinFactory("192.168.1.42") as device: print(type(device).__name__) # e.g. DaikinBRP069 print(device.inside_temperature) # e.g. 22.0 print(device.outside_temperature) # e.g. 34.5 print(device.target_temperature) # e.g. 24.0 device.show_values() # print all key/value pairs # BRP072Cxx (HTTPS + auth key) async with await DaikinFactory("192.168.1.43", key="MY_SECRET_KEY") as device: await device.update_status() print(device["mode"]) # e.g. 'cool' # SkyFi device (password required) async with await DaikinFactory("192.168.1.44", password="skyfi_pass") as device: await device.update_status() print(device.inside_temperature) # Shared aiohttp session async with aiohttp.ClientSession() as session: try: device = await DaikinFactory("192.168.1.42", session=session) await device.update_status() device.show_sensors() except DaikinException as exc: print(f"Connection failed: {exc}") asyncio.run(main()) ``` -------------------------------- ### Format Code with Ruff Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Use ruff to format your code according to project standards and sort imports. ```bash # Format code with ruff ruff format . ``` ```bash # Sort imports with ruff ruff check --select I --fix . ``` -------------------------------- ### Connect to Daikin AC and Update Status Source: https://github.com/fredrike/pydaikin/blob/master/README.md Use DaikinFactory to automatically detect device type and firmware, then connect and update the AC status. Requires aiohttp and asyncio. ```python import asyncio import logging import aiohttp from pydaikin.daikin_base import Appliance from pydaikin.factory import DaikinFactory HOST = "10.1.1.21" logging.basicConfig(level=logging.INFO) _LOGGER = logging.getLogger(__name__) async def main(): async with await DaikinFactory(HOST) as device: await device.update_status() device.show_sensors() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Lint Code with Ruff and Pylint Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Run ruff for general linting and checking. Pylint is also used and configured in the CI pipeline. ```bash # Run ruff ruff check ``` ```bash # Run pylint (configured in CI) pylint pydaikin ``` -------------------------------- ### Run Pytest Suite Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Execute the test suite using pytest. Options include running all tests, specific files, or with coverage reporting. ```bash # Run all tests pytest ``` ```bash # Run specific test file pytest tests/test_daikin_base.py ``` ```bash # Run with coverage report pytest --cov=pydaikin --cov-report=html ``` -------------------------------- ### Home Assistant Command Line Prompt Source: https://github.com/fredrike/pydaikin/wiki/Debugging-from-hassio This is the typical command line interface presented after logging into the Home Assistant OS via the SSH add-on. ```text ▄██▄ _ _ ▄██████▄ | | | | ___ _ __ ___ ___ ▄████▀▀████▄ | |_| |/ _ \| '_ ` _ \ / _ \ ▄█████ █████▄ | _ | (_) | | | | | | __/ ▄██████▄ ▄██████▄ |_| |_|\___/|_| |_| |_|\___| _ ████████ ██▀ ▀██ / \ ___ ___(_)___| |_ __ _ _ __ | |_ ███▀▀███ ██ ▄██ / _ \ / __/ __| / __| __/ _` | '_ \| __| ██ ██ ▀ ▄█████ / ___ \\__ \__ \ \__ \ || (_| | | | | |_ ███▄▄ ▀█ ▄███████ /_/ \_\___/___/_|___/\__\__,_|_| |_|\__| ▀█████▄ ███████▀ Welcome to the Home Assistant command line. System information IPv4 addresses for enp0s3: 192.168.1.5/24 IPv6 addresses for enp0s3: fd1b:86ac:99fa:6644:9bd6:2f1b:e8ff:86fb/64, fe80::5998:7388:afcf:b9b5/64 OS Version: Home Assistant OS 13.1 Home Assistant Core: 2024.8.1 Home Assistant URL: http://hassio.local:8123 Observer URL: http://hassio.local:4357 ~ $ ``` -------------------------------- ### Commit Changes Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Stage all changes and commit them with a clear and descriptive message. ```bash git add . git commit -m "Add feature: description of your changes" ``` -------------------------------- ### SSH Login Prompt Source: https://github.com/fredrike/pydaikin/wiki/Debugging-from-hassio This shows the login prompt for the SSH add-on, requiring the configured username and password. ```text ~ $ login a0d7b954-ssh login: home Password: ``` -------------------------------- ### set Source: https://context7.com/fredrike/pydaikin/llms.txt Sends a control command to the device to set temperature, mode, fan, and swing. The `settings` dict accepts human-readable keys. Mode 'off' powers the unit down; any other mode powers it on. Temperature is passed as a string. Fan and swing values are model-specific. ```APIDOC ## set ### Description Sends a control command to the device. The `settings` dict accepts human-readable keys. Mode `"off"` powers the unit down; any other mode powers it on. Temperature is passed as a string. Fan and swing values are model-specific. ### Method `device.set(settings: dict)` ### Parameters #### Request Body - **settings** (dict) - Required - A dictionary containing device settings. - **mode** (str) - Optional - The operating mode (e.g., "cool", "hot", "fan", "auto", "off"). - **stemp** (str) - Optional - The set temperature (e.g., "22"). - **f_rate** (str) - Optional - The fan speed (e.g., "auto", "5"). - **f_dir** (str) - Optional - The swing direction (e.g., "vertical", "3d"). ### Request Example ```python await device.set({ "mode": "cool", "stemp": "22", "f_rate": "auto", "f_dir": "vertical", }) ``` ### Response This method does not return a value, but applies the settings to the device. ``` -------------------------------- ### Discover Daikin Devices on the LAN Source: https://context7.com/fredrike/pydaikin/llms.txt Find Daikin devices on your local network using UDP broadcasts. `get_devices()` provides a convenient wrapper for discovery. Results include IP, MAC, name, and port. ```python import asyncio from pydaikin.discovery import Discovery, get_devices, get_name from pydaikin.factory import DaikinFactory # Synchronous discovery — scan all network interfaces def discover_all(): devices = get_devices() for dev in devices: print(f" IP: {dev['ip']}, MAC: {dev['mac']}, Name: {dev['name']}") return list(devices) # Look up a single device by its broadcast name def find_by_name(name: str): return get_name(name) # returns dict with 'ip', 'mac', 'port', or None # Targeted scan on a specific subnet broadcast def discover_on_subnet(broadcast_ip: str): d = Discovery() return list(d.poll(ip=broadcast_ip)) # Stop as soon as a specific device name is found def discover_until_found(name: str): d = Discovery() return list(d.poll(stop_if_found=name)) async def connect_discovered(): devices = get_devices() for dev in devices: try: async with await DaikinFactory(dev['ip']) as appliance: print(f"{dev['name']} @ {dev['ip']}: inside={appliance.inside_temperature}°C") except Exception as exc: print(f"Could not connect to {dev['ip']}: {exc}") discover_all() asyncio.run(connect_discovered()) ``` -------------------------------- ### Control Daikin Zones with AirBase and SkyFi Source: https://context7.com/fredrike/pydaikin/llms.txt Manage named zones on AirBase and SkyFi devices, including enabling/disabling and setting target temperatures. Requires `pydaikin.factory.DaikinFactory`. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): # AirBase example async with await DaikinFactory("192.168.1.45") as device: if device.zones: print("Zones:") for i, (name, onoff, temp) in enumerate(device.zones): print(f" [{i}] {name}: {'on' if onoff == '1' else 'off'}, {temp}°C") # Turn zone 0 on await device.set_zone(zone_id=0, key="zone_onoff", value="1") # Turn zone 1 off await device.set_zone(zone_id=1, key="zone_onoff", value="0") # Set zone 2 temperature (if supported) if device.support_zone_temperature: await device.set_zone(zone_id=2, key="lztemp", value="21") # SkyFi zone example async with await DaikinFactory("192.168.1.46", password="mypassword") as device: if device.zones: for i, (name, onoff) in enumerate(device.zones): print(f" [{i}] {name}: {onoff}") await device.set_zone(zone_id=0, key="zone_onoff", value="1") asyncio.run(main()) ``` -------------------------------- ### Energy consumption monitoring Source: https://context7.com/fredrike/pydaikin/llms.txt Provides access to energy consumption data and estimates instantaneous power usage. ```APIDOC ## Energy consumption monitoring ### Description `support_energy_consumption` indicates whether the device reports energy data. `energy_consumption(mode, time)` returns kWh for today, yesterday, last 7 days, this year, or last year. Properties `current_total_power_consumption`, `last_hour_cool_energy_consumption`, and `last_hour_heat_energy_consumption` estimate instantaneous power in kW from the consumption history. ### Methods & Properties #### `support_energy_consumption` (property) - **Description**: Boolean indicating if the device supports energy monitoring. #### `energy_consumption(mode: str, time: str)` (method) - **Description**: Returns energy consumption in kWh for a specified mode and time period. - **Parameters**: - **mode** (str) - Required - The type of consumption (e.g., `ATTR_TOTAL`, `ATTR_COOL`, `ATTR_HEAT`). - **time** (str) - Required - The time period (e.g., `TIME_TODAY`, `TIME_YESTERDAY`, `TIME_LAST_7_DAYS`, `TIME_THIS_YEAR`). #### `current_total_power_consumption` (property) - **Description**: Estimates instantaneous total power consumption in kW. #### `last_hour_cool_energy_consumption` (property) - **Description**: Estimates the cooling energy consumption in kW over the last hour. #### `last_hour_heat_energy_consumption` (property) - **Description**: Estimates the heating energy consumption in kW over the last hour. #### `today_energy_consumption` (property) - **Description**: Convenience property for today's total energy consumption in kWh. #### `today_cool_energy_consumption` (property) - **Description**: Convenience property for today's cooling energy consumption in kWh. #### `today_heat_energy_consumption` (property) - **Description**: Convenience property for today's heating energy consumption in kWh. ### Request Example ```python # Check if supported if device.support_energy_consumption: # Get energy consumption data today_total_kwh = device.energy_consumption(ATTR_TOTAL, TIME_TODAY) last_7_days_kwh = device.energy_consumption(ATTR_TOTAL, TIME_LAST_7_DAYS) # Access convenience properties print(f"Today's total consumption: {device.today_energy_consumption:.2f} kWh") # Update status to get latest power estimates await device.update_status() print(f"Current total power: {device.current_total_power_consumption:.3f} kW") ``` ### Response - **energy_consumption**: float (kWh) - **current_total_power_consumption**: float (kW) - **last_hour_cool_energy_consumption**: float (kW) - **last_hour_heat_energy_consumption**: float (kW) - **today_energy_consumption**: float (kWh) - **today_cool_energy_consumption**: float (kWh) - **today_heat_energy_consumption**: float (kWh) ``` -------------------------------- ### Create a New Feature or Fix Branch Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Create a new branch for your feature or bug fix using a descriptive naming convention. ```bash git checkout -b feature/your-feature-name ``` ```bash git checkout -b fix/your-bug-fix ``` -------------------------------- ### Clone PyDaikin Repository Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Clone your forked repository locally and add the upstream remote for tracking changes. ```bash git clone https://github.com/YOUR_USERNAME/pydaikin.git cd pydaikin ``` ```bash git remote add upstream https://github.com/fredrike/pydaikin.git ``` -------------------------------- ### Control Daikin Special Modes (Holiday, Advanced, Streamer) Source: https://context7.com/fredrike/pydaikin/llms.txt Utilize specific methods for special modes like holiday (away) mode, advanced modes (powerful, econo, streamer), and streamer toggle. Always check feature support before calling these methods. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: # Check feature support before calling if device.support_away_mode: await device.set_holiday("on") # enable away/holiday mode await device.set_holiday("off") # disable it if device.support_advanced_modes: # mode: 'streamer', 'powerful', or 'econo' await device.set_advanced_mode("powerful", "on") await device.set_advanced_mode("econo", "on") await device.set_advanced_mode("powerful", "off") print("Advanced mode:", device["adv"]) # e.g. '12' -> 'econo' # Streamer (air purifier) toggle await device.set_streamer("on") await device.set_streamer("off") asyncio.run(main()) ``` -------------------------------- ### Dynamically Set pydaikin Logging Level via Action Source: https://github.com/fredrike/pydaikin/wiki/Increase-logging-level Adjust log levels for specific components in real-time using the logger.set_level action. This is useful for debugging without restarting Home Assistant. ```yaml action: logger.set_level data: homeassistant.components.daikin: debug pydaikin: debug ``` -------------------------------- ### Skip Pre-commit Hooks Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Use the --no-verify flag with git commit to bypass pre-commit checks. This is generally not recommended. ```bash git commit --no-verify -m "Your commit message" ``` -------------------------------- ### Monitor Daikin Energy Consumption Source: https://context7.com/fredrike/pydaikin/llms.txt Check if the device supports energy monitoring before querying data. The `energy_consumption` method returns kWh for various periods. Convenience properties provide direct access to today's consumption. Instantaneous power estimates require periodic status updates. ```python import asyncio from pydaikin.factory import DaikinFactory from pydaikin.power import ATTR_COOL, ATTR_HEAT, ATTR_TOTAL from pydaikin.power import TIME_TODAY, TIME_YESTERDAY, TIME_LAST_7_DAYS, TIME_THIS_YEAR async def main(): async with await DaikinFactory("192.168.1.42") as device: if not device.support_energy_consumption: print("Energy monitoring not supported on this device") return # kWh values print(f"Today total: {device.energy_consumption(ATTR_TOTAL, TIME_TODAY):.2f} kWh") print(f"Today cooling: {device.energy_consumption(ATTR_COOL, TIME_TODAY):.2f} kWh") print(f"Today heating: {device.energy_consumption(ATTR_HEAT, TIME_TODAY):.2f} kWh") print(f"Yesterday total: {device.energy_consumption(ATTR_TOTAL, TIME_YESTERDAY):.2f} kWh") print(f"Last 7 days: {device.energy_consumption(ATTR_TOTAL, TIME_LAST_7_DAYS):.2f} kWh") print(f"This year: {device.energy_consumption(ATTR_TOTAL, TIME_THIS_YEAR):.2f} kWh") # Convenience properties print(f"Today combined: {device.today_energy_consumption:.2f} kWh") print(f"Today cool: {device.today_cool_energy_consumption:.2f} kWh") print(f"Today heat: {device.today_heat_energy_consumption:.2f} kWh") # Simulate a polling loop to build history for instantaneous power estimates import asyncio for _ in range(3): await device.update_status() await asyncio.sleep(5) print(f"Current power: {device.current_total_power_consumption:.3f} kW") print(f"Cool power/h: {device.last_hour_cool_energy_consumption:.3f} kW") print(f"Heat power/h: {device.last_hour_heat_energy_consumption:.3f} kW") asyncio.run(main()) ``` -------------------------------- ### Translate Daikin Codes to Human-Readable Values Source: https://context7.com/fredrike/pydaikin/llms.txt Use daikin_to_human, human_to_daikin, and daikin_values to convert between internal Daikin codes and user-friendly strings. Ensure the device subclass has a TRANSLATIONS dict defined. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: # Internal code → human string print(device.daikin_to_human("mode", "3")) # 'cool' print(device.daikin_to_human("f_rate", "A")) # 'auto' print(device.daikin_to_human("f_dir", "1")) # 'vertical' # Human string → internal code print(device.human_to_daikin("mode", "cool")) # '3' print(device.human_to_daikin("f_rate", "auto")) # 'A' # All human-readable values for a dimension print(device.daikin_values("mode")) # ['Auto', 'Auto-1', 'Auto-7', 'Cool', 'Dry', 'Fan', 'Hot', 'Off'] print(device.daikin_values("f_rate")) # ['1', '2', '3', '4', '5', 'Auto', 'Silence'] # represent() gives the translated key + value for display key, val = device.represent("mode") print(f"{key}: {val}") # e.g. "mode: cool" asyncio.run(main()) ``` -------------------------------- ### update_status: Refresh Device State Source: https://context7.com/fredrike/pydaikin/llms.txt Fetches the device's current sensor and control data. Supports optional force_refresh for BRP069/AirBase/BRP072C to bypass TTL cache and fetching specific endpoints. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: # Refresh all dynamic resources await device.update_status() # Force-refresh even TTL-cached resources (BRP069/AirBase/BRP072C only) await device.update_status(force_refresh=True) # Fetch only specific endpoints await device.update_status(["aircon/get_sensor_info", "aircon/get_control_info"]) print(f"Inside: {device.inside_temperature}°C") print(f"Outside: {device.outside_temperature}°C") print(f"Target: {device.target_temperature}°C") print(f"Mode: {device['mode']}") # raw Daikin value print(f"Power: {device['pow']}") # '0' = off, '1' = on print(f"Fan: {device['f_rate']}") print(f"Swing: {device['f_dir']}") print(f"MAC: {device.mac}") asyncio.run(main()) ``` -------------------------------- ### Push Changes to Git Fork Source: https://github.com/fredrike/pydaikin/blob/master/CONTRIBUTING.md Command to push your local changes to a specific branch on your Git fork. Ensure you replace 'feature/your-feature-name' with your actual branch name. ```bash git push origin feature/your-feature-name ``` -------------------------------- ### Control Daikin Device Temperature, Mode, Fan, and Swing Source: https://context7.com/fredrike/pydaikin/llms.txt Use the `set` method to control various aspects of your Daikin device. Mode 'off' powers down the unit, while other modes power it on. Temperature is set as a string. Fan and swing values are model-specific. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: # Cool to 22°C with fan on auto, swing vertical await device.set({ "mode": "cool", "stemp": "22", "f_rate": "auto", "f_dir": "vertical", }) # Heat to 20°C await device.set({"mode": "hot", "stemp": "20"}) # Fan-only mode await device.set({"mode": "fan"}) # Auto mode, 24°C, high fan speed, 3D swing await device.set({"mode": "auto", "stemp": "24", "f_rate": "5", "f_dir": "3d"}) # Power off await device.set({"mode": "off"}) # Show available mode/fan/swing choices for this device print("Modes:", device.daikin_values("mode")) # e.g. ['Auto', 'Auto-1', 'Auto-7', 'Cool', 'Dry', 'Fan', 'Hot', 'Off'] print("Fan rates:", device.fan_rate) # e.g. ['1', '2', '3', '4', '5', 'Auto', 'Silence'] print("Swing modes:", device.swing_modes) # e.g. ['3D', 'Horizontal', 'Off', 'Vertical'] asyncio.run(main()) ``` -------------------------------- ### Display and Log Daikin Device State Source: https://context7.com/fredrike/pydaikin/llms.txt Monitor Daikin device status by printing key/value pairs, sensor summaries, or logging sensor data to a CSV file. Requires `pydaikin.factory.DaikinFactory` and `update_status()`. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: await device.update_status() # Print summary (VALUES_SUMMARY keys only) device.show_values(only_summary=True) # e.g.: # firmware adapter: 1.2.3 # inside temp: 22.0 # ... # Print all known values device.show_values(only_summary=False) # One-line sensor printout device.show_sensors() # e.g.: 2024-05-01 12:00:00 in_temp=22°C out_temp=34°C cmp_freq=42Hz total_today=1.2kWh # CSV logging to a file with open("/tmp/daikin_log.csv", "a", encoding="utf-8") as f: for _ in range(3): await device.update_status() device.log_sensors(f) await asyncio.sleep(30) # File output: # datetime,in_temp,out_temp,cmp_freq,total_today,cool_today,heat_today,... # 2024-05-01 12:00:00,22,34,42,1.2,0.8,0.4,... asyncio.run(main()) ``` -------------------------------- ### update_status - Refresh device state Source: https://context7.com/fredrike/pydaikin/llms.txt The `update_status` method refreshes the Daikin device's current sensor and control data from its HTTP endpoints. For certain models, it supports caching and a `force_refresh` option. It can also be used to fetch specific endpoints. ```APIDOC ## update_status — refresh device state Fetches the device's current sensor and control data from its HTTP endpoints. For `DaikinBRP069`, static resources (basic info, model info) are cached forever; dynamic resources (sensor info, control info, power data) are re-fetched based on TTL. Pass `force_refresh=True` (BRP069 only) to bypass the TTL cache. ```python import asyncio from pydaikin.factory import DaikinFactory async def main(): async with await DaikinFactory("192.168.1.42") as device: # Refresh all dynamic resources await device.update_status() # Force-refresh even TTL-cached resources (BRP069/AirBase/BRP072C only) await device.update_status(force_refresh=True) # Fetch only specific endpoints await device.update_status(["aircon/get_sensor_info", "aircon/get_control_info"]) print(f"Inside: {device.inside_temperature}°C") print(f"Outside: {device.outside_temperature}°C") print(f"Target: {device.target_temperature}°C") print(f"Mode: {device['mode']}") # raw Daikin value print(f"Power: {device['pow']}") # '0' = off, '1' = on print(f"Fan: {device['f_rate']}") print(f"Swing: {device['f_dir']}") print(f"MAC: {device.mac}") asyncio.run(main()) ``` ``` -------------------------------- ### set_holiday / set_advanced_mode / set_streamer Source: https://context7.com/fredrike/pydaikin/llms.txt Controls special modes including holiday/away mode, advanced modes like powerful/econo/streamer, and a direct toggle for the air purification streamer. ```APIDOC ## set_holiday / set_advanced_mode / set_streamer ### Description `set_holiday` enables or disables away mode. `set_advanced_mode` toggles powerful, econo, or streamer sub-modes. `set_streamer` is a shortcut to toggle the air purification streamer on or off. ### Methods #### `set_holiday(state: str)` - **Description**: Enables or disables away/holiday mode. - **Parameters**: - **state** (str) - Required - "on" to enable, "off" to disable. #### `set_advanced_mode(mode: str, state: str)` - **Description**: Toggles advanced modes like 'powerful', 'econo', or 'streamer'. - **Parameters**: - **mode** (str) - Required - The advanced mode to control ('streamer', 'powerful', or 'econo'). - **state** (str) - Required - "on" to enable, "off" to disable. #### `set_streamer(state: str)` - **Description**: Toggles the air purification streamer on or off. - **Parameters**: - **state** (str) - Required - "on" to enable, "off" to disable. ### Request Example ```python # Enable away mode await device.set_holiday("on") # Enable powerful mode await device.set_advanced_mode("powerful", "on") # Toggle streamer await device.set_streamer("on") ``` ### Response These methods do not return a value but apply the specified mode changes to the device. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.