### Install Dependencies with uv Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/visualize/README.md Installs project dependencies using uv. Ensure you are in the `utils/visualize` directory before running. ```bash cd utils/visualize uv sync ``` -------------------------------- ### Start Measurements Natively Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/measure/README.md Execute the powercalc measurement script using Python after native setup. This command runs the main measurement module. ```bash uv run python -m measure.measure ``` -------------------------------- ### Verify Docker Installation Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/setup.md Verify that Docker is installed and running before proceeding with Docker-based setup. ```bash docker version ``` -------------------------------- ### Install Development Dependencies with uv Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/integration-development.md Install project dependencies for development and testing using the 'uv' package manager. Ensure 'uv' is installed first. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh uv sync --locked --group=dev tests/setup.sh ``` -------------------------------- ### Example Exported Files Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/lights.md Illustrates the typical file structure and names generated after a successful light measurement run. ```text export//model.json export//brightness.csv.gz export//color_temp.csv.gz export//hs.csv.gz export//effect.csv.gz ``` -------------------------------- ### Basic UPS Configuration with Fixed Strategy Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/cookbook/ups.md Use the fixed strategy for simple UPS setups where approximate power consumption for different states is known. This example uses a template to determine power based on the charging state. ```yaml powercalc: sensors: - entity_id: binary_sensor.ups_charging name: UPS Power Consumption fixed: power: >- {% if is_state('binary_sensor.ups_charging', 'on') %} 35 # Power consumption when charging {% else %} 5 # Standby power consumption {% endif %} ``` -------------------------------- ### Multi Switch Configuration Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/multi-switch.md Configure a multi switch sensor by providing a list of individual switch entities and their power consumption when on and off. This setup allows for accurate power tracking of combined outlets. ```yaml powercalc: sensors: - name: "My outlet self usage" multi_switch: entities: - switch.outlet_1 - switch.outlet_2 - switch.outlet_3 power_off: 0.25 power: 0.5 ``` -------------------------------- ### Activate Playbook Automation Action Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/playbook.md Example Home Assistant automation to manually start a specific playbook using the `activate_playbook` action. This is triggered by a state change. ```yaml description: "Activate washing machine power playbook when program starts" mode: single trigger: - platform: state entity_id: - sensor.washing_machine_job_state to: program1 action: - action: powercalc.activate_playbook data: playbook_id: program1 target: entity_id: sensor.washing_machine_power ``` -------------------------------- ### Start Measurements with Docker (Windows) Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/measure/README.md Run the powercalc-measure Docker image on Windows. Ensure Docker is installed and an .env file is configured. Mounts local directories for export and persistent data. Note: PowerShell may require full paths. ```bash docker run --pull=always --rm --name=measure --env-file=.env -v %CD%/export:/app/export -v %CD%/.persistent:/app/.persistent -it bramgerritsen/powercalc-measure:latest ``` -------------------------------- ### Basic Composite Strategy Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/composite.md This example demonstrates a basic composite strategy where one fixed power value is used when a specific condition is met, and a different fixed value is used otherwise. The conditions engine is the same as used in Home Assistant automations and scripts. ```yaml powercalc: sensors: - entity_id: switch.heater composite: # This indicates the composite strategy is used - condition: condition: state entity_id: select.heater_mode state: high fixed: power: 1000 - fixed: power: 500 ``` -------------------------------- ### Start Home Assistant Core in Development Mode Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/integration-development.md Run Home Assistant Core with the development flag, pointing to your configuration directory. ```bash hass -c /path/to/your/homeassistant/config --dev ``` -------------------------------- ### Example model.json Configuration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/light.md This JSON configuration is used for lights employing the LUT calculation strategy. Ensure all required fields are present for proper integration. ```json { "standby_power": 0.4, "calculation_strategy": "lut" } ``` -------------------------------- ### Profile File Placement Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/output.md Place new device profiles under the 'profile_library' directory, organized by manufacturer and model ID. Use the model ID for the directory name. ```text profile_library/// model.json hs.csv.gz color_temp.csv.gz ``` -------------------------------- ### Native Python Setup with uv Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/measure/README.md Set up the powercalc-measure tool natively using Python and uv. This involves navigating to the directory, creating a virtual environment, and syncing dependencies. ```bash cd utils/measure uv venv uv sync --extra dev ``` -------------------------------- ### Simplest Fixed Strategy Configuration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/fixed.md Use this configuration when you have a fixed power consumption for an appliance when it's turned on. No additional setup is required. ```yaml powercalc: sensors: - entity_id: light.nondimmabled_bulb fixed: power: 20 ``` -------------------------------- ### Smart Speaker JSON Configuration Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/smart-speaker.md Example model.json configuration for a smart speaker device type. Note that required fields are omitted for brevity. This configuration defines how power consumption is calculated based on volume levels. ```json { "calculation_enabled_condition": "{{ is_state('[[entity]]', 'playing') }}", "calculation_strategy": "linear", "device_type": "smart_speaker", "linear_config": { "calibrate": [ "10 -> 1.79", "20 -> 1.79", "30 -> 1.86", "40 -> 1.93", "50 -> 1.94", "60 -> 2.09", "70 -> 2.34", "80 -> 2.3", "90 -> 2.43", "100 -> 2.51", "0 -> 1.63" ] }, "standby_power": 0.9 } ``` -------------------------------- ### Example Playbook CSV Content Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/playbook.md This is an example of the content for a playbook CSV file. Each line represents a point in time and the desired power consumption at that time. ```csv 0.5,70 2,90 4,25.5 10,120 15,80 20,0 ``` -------------------------------- ### Stop Playbook Service Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/stop-playbook.md An example of how to call the `powercalc.stop_playbook` service to stop a playbook associated with a virtual power sensor. ```APIDOC ## powercalc.stop_playbook ### Description Stops a running playbook on a virtual power sensor. ### Method service ### Endpoint powercalc.stop_playbook ### Parameters #### Service Data - **playbook_id** (string) - Required - The ID of the playbook to stop. - **entity_id** (string) - Required - The entity ID of the virtual power sensor. ### Request Example ```yaml action: powercalc.stop_playbook data: playbook_id: program1 target: entity_id: sensor.waching_machine_power ``` ### Response #### Success Response (200) This service does not return a response body on success. ``` -------------------------------- ### Composite Strategy with 'sum_all' Mode Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/composite.md This example illustrates the 'sum_all' mode for the composite strategy. In this mode, all strategies that match the conditions are applied, and their power values are summed. If no strategy matches, the power sensor will report 0. ```yaml powercalc: sensors: - entity_id: humidifier.test composite: mode: sum_all strategies: - condition: condition: state entity_id: input_boolean.motor1 state: on fixed: power: 1000 - fixed: power: 500 ``` -------------------------------- ### Clone Powercalc Repository and Setup Remotes Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/integration-development.md Clone the Powercalc repository and add the upstream remote for contributing. Replace YOUR_GIT_USERNAME with your GitHub username. ```bash git clone https://github.com/YOUR_GIT_USERNAME/homeassistant-powercalc cd homeassistant-powercalc git remote add upstream https://github.com/bramstroker/homeassistant-powercalc.git ``` -------------------------------- ### Stop Playbook Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/stop-playbook.md Use this service to stop a running playbook. It requires the playbook ID and the entity ID of the virtual power sensor. ```yaml action: powercalc.stop_playbook data: playbook_id: program1 target: entity_id: sensor.waching_machine_power ``` -------------------------------- ### Basic Playbook Setup with Existing Entity Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/playbook.md Configure a playbook sensor linked to an existing entity. This automatically adds the powercalc sensor to the device in the Home Assistant UI. ```yaml powercalc: sensors: - entity_id: switch.washing_machine playbook: playbooks: program1: program1.csv program2: program2.csv ``` -------------------------------- ### Run All Tests with pytest Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/integration-development.md Execute all tests in the 'tests/' directory using pytest after installing dependencies. ```bash uv run pytest tests/ ``` -------------------------------- ### Standalone Playbook Sensor Setup Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/playbook.md Create a standalone playbook sensor when no existing entity is available to bind to. This allows for custom naming and multiple playbook definitions. ```yaml powercalc: sensors: - entity_id: sensor.dummy name: Washing Machine playbook: playbooks: program1: washing_machine_normal.csv program2: washing_machine_eco.csv quick_wash: washing_machine_quick.csv ``` -------------------------------- ### Configure WLED Sensor with YAML Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/wled.md Example of setting up a WLED power sensor using YAML configuration. Ensure the brightness limiter is enabled in WLED for accurate readings. The voltage is a required parameter. ```yaml powercalc: sensors: - entity_id: light.wled_lightstrip wled: voltage: 5 ``` -------------------------------- ### Configure Device Standby Power Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/group/standby.md Example of configuring a device with its specific standby power consumption in watts. ```yaml powercalc: entities: - entity_id: switch.my_device standby_power: 0.5 # 0.5W of standby power when the device is OFF # other configuration... ``` -------------------------------- ### Basic Linear Configuration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/linear.md Configure a light entity using the linear strategy with minimum and maximum power values. This is a basic setup for dimmable devices. ```yaml powercalc: sensors: - entity_id: light.livingroom_floorlamp linear: min_power: 0.5 max_power: 8 ``` -------------------------------- ### Camera Device Configuration JSON Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/camera.md Example JSON configuration for a camera device. Specifies the device type as 'camera' and uses a 'fixed' calculation strategy with a fixed power consumption. ```json { "device_type": "camera", "calculation_strategy": "fixed", "fixed_config": { "power": 2.5 } } ``` -------------------------------- ### powercalc.activate_playbook Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/activate-playbook.md Starts executing a playbook on virtual power sensors. This service requires the playbook strategy to be configured for the target virtual power sensor. ```APIDOC ## activate_playbook ### Description Starts executing a playbook on virtual power sensors. This service requires the playbook strategy to be configured for the target virtual power sensor. ### Method POST ### Endpoint /services/powercalc/activate_playbook ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **playbook_id** (string) - Required - The ID of the playbook to activate. - **entity_id** (string) - Required - The entity ID of the virtual power sensor. ### Request Example ```json { "playbook_id": "program1", "entity_id": "sensor.waching_machine_power" } ``` ### Response #### Success Response (200) This service does not return a response body on success. #### Response Example None ``` -------------------------------- ### Cover Device Configuration (JSON) Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/cover.md Example JSON configuration for a cover device. This profile is for a cover device that uses 150W when opening or closing, with a standby power of 0.2W. Required fields are omitted for brevity. ```json { "standby_power": 0.2, "standby_power_on": 0.2, "device_type": "cover", "calculation_strategy": "fixed", "fixed_config": { "states_power": { "opening": 150, "closing": 150 } } } ``` -------------------------------- ### Example Response for get_group_entities Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/get-group-entities.md The response from the `powercalc.get_group_entities` service lists the member entities under the 'entities' key. ```yaml sensor.tracked_power: entities: - sensor.kitchen_light_power - sensor.furnace_power - sensor.magic_power ``` -------------------------------- ### Combining AND and NOT Filters Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/group/include-entities.md Demonstrates combining 'and' and 'not' filters to create sophisticated inclusion rules. This example includes lights from the living room but excludes those matching a specific wildcard pattern. ```yaml powercalc: sensors: - create_group: Complex filter example include: domain: light filter: and: - area: living_room - not: - wildcard: "*ignore*" ``` -------------------------------- ### Printer Device Configuration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/printer.md Example JSON configuration for a printer device. Specifies 'fixed' calculation strategy and defines power states for 'idle' and 'printing'. Required fields are omitted for brevity. ```json { "calculation_strategy": "fixed", "device_type": "printer", "fixed_config": { "states_power": { "idle": 1.52, "printing": 12 } } } ``` -------------------------------- ### Run OCR stream utility Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/measure-ocr.md Execute the OCR main script. Specify the path to your Tesseract binary using the -t flag. Ensure Python 3.10 and necessary requirements are installed. ```shell python ocr/main.py -t '{tesseract_binary}' ``` ```shell python ocr/main.py -t '/opt/homebrew/Cellar/tesseract/5.1.0/bin/tesseract' ``` -------------------------------- ### Composite Strategy with Nested Conditions Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/composite.md This example shows a composite strategy with more complex, nested conditions using AND and OR logic. It also includes a fallback strategy that is applied when no other conditions match. Ensure that 'condition' is omitted only on the last strategy to act as a fallback. ```yaml powercalc: sensors: - entity_id: light.test composite: # First strategy (fixed) using nested AND and OR conditions - condition: condition: and conditions: - condition: state entity_id: binary_sensor.test state: on - condition: or conditions: - condition: numeric_state entity_id: sensor.test above: 20 below: 40 - condition: template value_template: "{{ is_state('sensor.test2', 'test') }}" fixed: power: 10 # Second strategy (linear) - condition: condition: state entity_id: binary_sensor.test state: off linear: min_power: 20 max_power: 40 ``` -------------------------------- ### Switch Sub Profile Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/switch-sub-profile.md Use this action in your Home Assistant automations to change the sub-profile of an entity. Ensure the entity supports multiple sub-profiles and specify the desired profile name. ```yaml action: powercalc.switch_sub_profile data: profile: length_5 target: entity_id: sensor.my_light_power ``` -------------------------------- ### Power Meter Configuration - JSON Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/power-meter.md Example JSON configuration for a power meter device type. This defines the standby power, sensor naming, and calculation strategy. Required fields are omitted for brevity. ```json { "standby_power": 0.3, "sensor_config": { "power_sensor_naming": "{} Device Power", "energy_sensor_naming": "{} Device Energy" }, "device_type": "power_meter", "calculation_strategy": "fixed", "discovery_by": "device", "only_self_usage": true } ``` -------------------------------- ### Enable Outlier Filter with Custom Max Step Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/configuration/outlier-filter.md Example of enabling the outlier filter and setting a custom maximum expected step for power values in watts. This configuration helps to filter out significant power spikes that are not considered normal transitions. ```yaml sensor: - platform: powercalc power_sensor_id: sensor.stove_power energy_filter_outlier_enabled: true energy_filter_outlier_max_step: 2500 # Set maximum expected step to 2500W ``` -------------------------------- ### Autostart and Repeat Playbook Configuration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/playbook.md Configure a playbook to autostart on Home Assistant startup and repeat after completion. Ideal for cyclical power patterns like refrigerators. ```yaml powercalc: sensors: - entity_id: sensor.dummy name: Refrigerator playbook: playbooks: cycle: refrigerator_cycle.csv autostart: cycle repeat: true ``` -------------------------------- ### Build Documentation with Zensical Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/AGENTS.md Use this command to build the documentation from the docs/ directory. The --clean flag ensures a fresh build. ```bash uv run --group docs zensical build --clean ``` -------------------------------- ### Debug Group Service Response Example Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/debug-group.md This is an example of the response you might receive when calling the `powercalc.debug_group` service for a power group. It shows the group's state, unit, and the state and unit of its members. ```yaml sensor.my_group_power: state: "150.00" unit_of_measurement: W members: sensor.kitchen_light_power: state: "50.00" unit_of_measurement: W sensor.furnace_power: state: "100.00" unit_of_measurement: W ``` -------------------------------- ### Set up Native Python Environment Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/setup.md Set up the native Python environment for the measure tool. This involves creating a virtual environment, syncing dependencies, and running the tool. ```bash cd utils/measure uv venv uv sync --extra dev uv run python -m measure.measure ``` -------------------------------- ### Include all power sensors Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/group/include-entities.md Include all available powercalc sensors and other power sensors in the Home Assistant installation. This can be combined with other filters. ```yaml powercalc: sensors: - create_group: General include: all: ``` -------------------------------- ### Define variables for YAML sensors Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/variables.md Pass required variables to a profile when defining a YAML sensor. This example shows how to pass a switch entity. ```yaml powercalc: sensors: - entity_id: light.your_light_entity manufacturer: "some_manufacturer" model: "some_model" variables: switch_entity: switch.your_switch_entity ``` -------------------------------- ### Basic YAML Configuration for Virtual Power Sensor Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/virtual-power-manual.md Use this basic configuration in configuration.yaml to set up a virtual power sensor with a fixed power value. Ensure you restart Home Assistant after changes. ```yaml powercalc: sensors: - entity_id: light.my_light fixed: power: 20 ``` -------------------------------- ### Remove YAML Configuration for Powercalc Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/misc/uninstall.md If Powercalc was added to your configuration.yaml, remove the relevant lines. This example shows a typical configuration block to be removed. ```yaml powercalc: # Your Powercalc configuration here ``` -------------------------------- ### Linear Configuration with Calibration Table Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/linear.md Set up a light entity with the linear strategy using a calibration table for more accurate power estimation. The table maps brightness levels (1-255) to power consumption. ```yaml powercalc: sensors: - entity_id: light.livingroom_floorlamp linear: calibrate: - 1 -> 0.3 - 10 -> 1.25 - 50 -> 3.50 - 100 -> 6.8 - 255 -> 15.3 ``` -------------------------------- ### Configure PowerCalc Integration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/INFO.md Add this entry to your configuration.yaml file to enable the PowerCalc integration. Restart Home Assistant after adding. ```yaml powercalc: ``` -------------------------------- ### Define a custom number field Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/variables.md Add a custom number field to a profile configuration. This example defines a number selector with min, max, and step values. ```json { "calculation_strategy": "fixed", "fields": { "num_switches": { "label": "Number of switches", "description": "Enter some number", "selector": { "number": { "min": 0, "max": 4, "step": 1 } } } }, "fixed_config": { "power": "{{ [[num_switches]] * 0.20 }}" } } ``` -------------------------------- ### Example JSON Payload for Analytics Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/misc/analytics.md This JSON structure represents the aggregated usage data that may be sent by Powercalc. It includes counts for various configurations and versions. ```json { "counts": { "by_model": { "signify:LCT024": 2, "signify:LLC010": 2, "shelly:shelly plug s": 1 }, "by_config_type": { "gui": 8 }, "by_sensor_type": { "group": 1, "real_power": 1, "virtual_power": 6 }, "by_manufacturer": { "shelly": 1, "signify": 4 }, "by_device_type": { "light": 4, "plug": 1 }, "by_strategy": { "lut": 4, "fixed": 1 }, "by_source_domain": { "light": 4, "switch": 1 }, "by_group_type": { "custom": 1, "standby": 1 }, "by_entity_type": { "power_sensor": 5, "energy_sensor": 3 } }, "ha_version": "2025.10.0.dev0", "install_id": "081ac191-2667-4242-8226-ecc66b1f7e9e", "install_date": "2023-01-15T12:34:56.789012", "language": "en", "group_sizes": { "2": 1, "5": 1 }, "powercalc_version": "0.1.1", "config_entry_count": 8, "custom_profile_count": 12, "has_global_gui_config": true, "has_group_include": false } ``` -------------------------------- ### Configure Fan Measurement Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/modes.md Configure environment variables for Home Assistant integration when measuring fan power consumption. This setup is similar to the smart speaker mode. ```env FAN_CONTROLLER=hass HASS_URL=http://homeassistant.local:8123/api HASS_TOKEN=your_long_lived_access_token ``` -------------------------------- ### Run Measure Tool with Docker (Windows Command Prompt) Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/setup.md Execute the measure tool container on Windows using the command prompt. Ensure you are in the directory containing your .env file. This command mounts local export and persistent directories into the container. Use absolute paths for mounted directories when using PowerShell. ```bat docker run --pull=always --rm --name=measure --env-file=.env -v %CD%/export:/app/export -v %CD%/.persistent:/app/.persistent -it bramgerritsen/powercalc-measure:latest ``` -------------------------------- ### Fixed Strategy with Templated Power Value Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/fixed.md Configure a dynamic power value using a Home Assistant template. This is useful when the power consumption can vary and is controlled by another entity. ```yaml powercalc: sensors: - entity_id: light.bathroom fixed: power: "{{states('input_number.bathroom_watts')}}" ``` -------------------------------- ### Call powercalc.get_group_entities Service Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/actions/get-group-entities.md Use this service to get a list of entity IDs that are part of a group. Ensure the group entity ID is correctly specified in the target. ```yaml action: powercalc.get_group_entities target: entity_id: sensor.my_group_power data: {} ``` -------------------------------- ### Create Group Sensor for All Energy Sensors Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/group/domain.md Configure Powercalc to create a group sensor that sums all energy sensors in your Home Assistant installation by using the 'all' keyword. ```yaml powercalc: create_domain_groups: - all ``` -------------------------------- ### Define a custom entity field Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/variables.md Add a custom field to a profile configuration to allow users to provide additional data. This example defines a switch entity selector. ```json { "fields": { "switch_entity": { "label": "Switch entity", "description": "Select the switch entity for your device", "selector": { "entity": { "domain": "switch" } } } } } ``` -------------------------------- ### Configure General and Tariff Utility Meters Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/utility-meter.md Create both a general utility meter and specific tariff-based meters by including 'general' along with other tariff names. This ensures a standard utility meter is created in addition to the tariff-specific ones. ```yaml powercalc: utility_meter_tariffs: - general - peak - offpeak ``` -------------------------------- ### Create Group Sensors for Specific Domains Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/group/domain.md Configure Powercalc to create group sensors for entities belonging to specified domains. This example groups sensors for lights and media players. ```yaml powercalc: create_domain_groups: - light - media_player ``` -------------------------------- ### Build and Run Docker Image Locally Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/utils/measure/README.md Build the powercalc-measure Docker image locally and then run it. This is useful for development or testing the image before pushing. ```bash docker build -t measure . docker run --rm --name=measure --env-file=.env -v $(pwd)/export:/app/export -v $(pwd)/.persistent:/app/.persistent -it measure ``` -------------------------------- ### Configure Home Assistant Controller Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/lights.md Set environment variables to configure the powercalc tool to use the Home Assistant controller for measuring lights. ```env LIGHT_CONTROLLER=hass HASS_URL=http://homeassistant.local:8123/api HASS_TOKEN=your_long_lived_access_token ``` -------------------------------- ### Configure Tariffs for Utility Meters Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/utility-meter.md Set up multiple utility meters to handle different tariffs, such as 'peak' and 'offpeak'. This globally configures the tariffs for all relevant sensors. An additional 'select' entity is created to manage the active tariff. ```yaml powercalc: utility_meter_tariffs: - peak - offpeak ``` -------------------------------- ### Enable Analytics via YAML Configuration Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/misc/analytics.md To enable analytics, add this configuration to your `configuration.yaml` file. Ensure analytics is not already disabled via GUI. ```yaml powercalc: enable_analytics: true ``` -------------------------------- ### Linear Configuration for Sensor with Percentage Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/linear.md Configure a non-light/fan entity (e.g., a sensor) using the linear strategy with a calibration table. The state values represent percentages (1-100) and map to power consumption. ```yaml powercalc: sensors: - entity_id: sensor.heater_modulation name: Heater linear: calibrate: - 1 -> 200 - 100 -> 1650 ``` -------------------------------- ### Globally Excluding Non-Powercalc Sensors Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/group/include-entities.md Configure 'include_non_powercalc_sensors' globally to 'false' to apply this setting to all group sensors in your configuration. This is a convenient way to manage sensor inclusion across your entire setup. ```yaml powercalc: include_non_powercalc_sensors: false ``` -------------------------------- ### Select a Sub-Profile via YAML Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/virtual-power-library.md Append a sub-profile to the model name, separated by a slash, to manually select a specific configuration for a virtual power sensor. ```yaml powercalc: sensors: - entity_id: light.my_light manufacturer: lifx model: LIFX Z/length_9 ``` -------------------------------- ### Run Measure Tool with Docker (Linux/macOS) Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/setup.md Execute the measure tool container on Linux or macOS. Ensure you are in the directory containing your .env file. This command mounts local export and persistent directories into the container. ```bash docker run --pull=always --rm --name=measure --env-file=.env -v $(pwd)/export:/app/export -v $(pwd)/.persistent:/app/.persistent -it bramgerritsen/powercalc-measure:latest ``` -------------------------------- ### Enable Per-Device Discovery Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/structure.md Set 'discovery_by' to 'device' to enable per-device discovery, which is more reliable than per-entity discovery, especially for sensor-based device types. ```json "discovery_by": "device" ``` -------------------------------- ### Sensors Defined in Separate Powercalc YAML File Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/sensor-types/virtual-power-manual.md When using an included YAML file for Powercalc configuration, omit the top-level 'powercalc:' key and list sensors directly. This example shows two virtual power sensors. ```yaml sensors: - entity_id: light.my_light fixed: power: 20 - entity_id: light.my_light2 fixed: power: 40 ``` -------------------------------- ### LUT Sensor Configuration with Sub-Profile (YAML) Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/lut.md Configure a virtual power sensor for lights that require a sub-profile, like certain LIFX models with specific modes (e.g., infrared). Specify the sub-profile directory within the model name. ```yaml powercalc: sensors: - entity_id: light.lifx_nighvision manufacturer: lifx model: LIFX BR30 Night Vision/infrared_25 ``` -------------------------------- ### Change Friendly Naming for Energy Sensors Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/misc/naming.md Separately change the friendly name displayed in the GUI for energy sensors without affecting the entity ID. This example sets a custom friendly name while also adjusting the entity suffix. ```yaml powercalc: energy_sensor_naming: "{} kwh" energy_sensor_friendly_naming: "{} Energy consumed" ``` -------------------------------- ### Composite Strategy Configuration in Library Profiles Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/strategies/composite.md This JSON snippet shows how to configure the composite strategy within library profiles. It includes two strategies: one with a numeric state condition and a fixed power, and a fallback fixed power strategy. ```json { "calculation_strategy": "composite", "composite_config": [ { "condition": { "condition": "numeric_state", "above": 17 }, "fixed": { "power": 0.82 } }, { "fixed": { "power": 0.52 } } ] } ``` -------------------------------- ### Enable Analytics via YAML Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/quick-start.md Add this entry to configuration.yaml to enable analytics. Remove the line if you do not want to provide analytics. ```yaml powercalc: enable_analytics: true # optional, remove this line when you don't want to provide analytics ``` -------------------------------- ### Smart Dimmer Configuration (No Powermeter) Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/library/device-types/smart-dimmer.md Use this JSON configuration for smart dimmers that do not have a built-in powermeter. The connected light's power consumption needs to be provided separately. Required fields are omitted for brevity. ```json { "standby_power": 0.3, "standby_power_on": 0.5, "device_type": "smart_dimmer", "calculation_strategy": "linear" } ``` -------------------------------- ### Configure Extra Wait Times for Light Transitions Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/setup.md Set specific wait times for different light transition types (hue, saturation, color temperature, effects) to ensure accurate readings after state changes. ```env SLEEP_TIME_HUE=2 SLEEP_TIME_SAT=2 SLEEP_TIME_CT=1 SLEEP_TIME_EFFECT_CHANGE=5 ``` -------------------------------- ### Configure Smart Speaker Measurement Source: https://github.com/bramstroker/homeassistant-powercalc/blob/master/docs/source/contributing/measure/modes.md Set up environment variables for Home Assistant integration when measuring smart speaker power consumption. Ensure your Home Assistant URL and token are correctly configured. ```env MEDIA_CONTROLLER=hass HASS_URL=http://homeassistant.local:8123/api HASS_TOKEN=your_long_lived_access_token ```