{"id":20801080,"url":"https://github.com/jugla/battery_consumption","last_synced_at":"2025-10-08T17:51:57.878Z","repository":{"id":164968089,"uuid":"403062943","full_name":"jugla/battery_consumption","owner":"jugla","description":"Home Assistant Component to compute battery consumption","archived":false,"fork":false,"pushed_at":"2024-09-07T21:08:01.000Z","size":67,"stargazers_count":18,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T04:22:47.277Z","etag":null,"topics":["battery","consumption","hacs","homeassistant"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jugla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-04T13:26:02.000Z","updated_at":"2025-01-04T11:39:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"e351b35e-4c1b-4200-a5f0-0393b50720d9","html_url":"https://github.com/jugla/battery_consumption","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jugla%2Fbattery_consumption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jugla%2Fbattery_consumption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jugla%2Fbattery_consumption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jugla%2Fbattery_consumption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jugla","download_url":"https://codeload.github.com/jugla/battery_consumption/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788529,"owners_count":21804284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["battery","consumption","hacs","homeassistant"],"created_at":"2024-11-17T18:16:27.156Z","updated_at":"2025-10-08T17:51:57.812Z","avatar_url":"https://github.com/jugla.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# battery_consumption\n\nBattery Consumption custom component for [Home Assistant](https://home-assistant.io/).\n\n\n![GitHub release](https://img.shields.io/github/release/jugla/battery_consumption)\n[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/home-assistant/brands/blob/master/custom_integrations/battery_consumption/icon%402x.png\" alt=\"icon battery consumtion\" width=\"400\"\u003e\n\u003c/p\u003e\n\nThis component is used to compute statistics on a battery (based on its level state)\n\nThis component allows to display :\n- the current varation of battery\n- the charge in % or in Wh/kWh...\n- the discharge in % or in Wh/kWh ...\n- the total charge/discharge\n\nThe refresh rate is based on battery's level state\n\n## Installation\nEither use HACS (default), either manual\n### [HACS](https://hacs.xyz/) (Home Assistant Community Store)\n1. Go to HACS page on your Home Assistant instance \n1. Select `integration` \n1. Press add icon and search for `battery_consumption` \n1. Select battery_consumption and install \n\n### Manual\n\u003cdetails\u003e\u003csummary\u003eManual Procedure\u003c/summary\u003e\n  \n1. Download the folder battery_consumption from the latest [release](https://github.com/jugla/battery_consumption/releases) (with right click, save \nlink as) \n1. Place the downloaded directory on your Home Assistant machine in the `config/custom_components` folder (when there is no `custom_components` folder in the \nfolder where your `configuration.yaml` file is, create it and place the directory there) \n1. restart HomeAssistant\n\u003c/details\u003e\n\n## Breaking change\nNone\n\n## Using the component\nin configuration.yaml, declare :\n\n```yaml\n##configuration.yaml example\nbattery_consumption:\n    zoe:\n       source: sensor.battery_level\n#      attribute : attribute of source to monitor\n#      unique_id : to set a unique id to this sensor\n#      precision : the precision of state\n       unit_of_measurement: kWh\n       battery_capacity: 41\n    galaxy_s7:\n       source: sensor.sm_g930f_niveau_de_batterie\n       unit_of_measurement: Wh\n       battery_capacity: 11.55\n\n``` \nwhere :\n- source is name of the state to monitor\n- attribute is the attribute of source to monitor\n- unique_id is to set a unique id to this sensor\n- precision is the precision you set (default 2)\n- battery_capacity is the capacity of the monitored battery\n- unit_of_measurement is the unit of capacity : kWh, Wh, ...\n\n*Only source* item is required\n\n\u003c/details\u003e\n\n## Sensor and attribute\nFor each battery to monitor one sensor is created.\n| sensor name | support | unit | Description |\n| ---------------|---------|-------|------------------------------------------|\n| battery_consumption+*name of sensor to monitor* | V1.0.0 | % | the current value of battery to monitor |\n\n\nThe sensor is created with the following attribute :\n\n| Attribute name | support | present | unit | Description |\n| ---------------|---------|-------|------|------------------------------------|\n| Source | V1.0.0 | always | string | the name of battery to monitor | \n| Previous value | V1.0.0 |  always | % | the previous value of battery to monitor |\n| Last updated | V2.0.0 |  always | time and date | the time when battery consumption has been updated |\n| Previous last updated | V2.0.0 |  always | time and date | the time when previous value has been updated |\n| Delta last updated in minutes | V2.0.0 |  always | mn | delta time between current and previous value |\n| Variation | V1.0.0 |  always | % | the difference between current and previous value |\n| Battery charge | V1.0.0 |  always | % | the difference between current and previous value if positive (battery is charging) |\n| Battery discharge | V1.0.0 |  always | % | the difference between current and previous value if negative (battery is discharging) |\n| Total charge | V1.0.0 |  always | % | the sum of all *battery charge* since the beginning | \n| Total discharge | V1.0.0 |  always | % | the sum of all *battery discharge* since the beginning |\n| Capacity unit | V1.0.0 |  if capacity given | kWh , Wh, ... | the unif of the capacity of the battery cf. yaml |\n| Capacity | V1.0.0 |  if capacity given  | kWh , Wh, ...  | the capacity of the battery cf. yaml |\n| Energy level | V2.0.0 |  if capacity given | kWh , Wh, ... | the Energy value respect to battery level (current state) |\n| Energy Variation | V2.0.0 |  if capacity given | kWh , Wh, ... | the difference between current and previous Energy value |\n| Energy charge | V1.0.0 |  if capacity given | kWh , Wh, ... | the *battery charge* converted in energy |\n| Energy discharge | V1.0.0 |  if capacity given | kWh , Wh, ... | the *battery discharge* converted in energy |\n| Total energy charge | V1.0.0 |  if capacity given | kWh , Wh, ... | the *total battery charge* converted in energy |\n| Total energy discharge | V1.0.0 |  if capacity given | kWh , Wh, ... | the *total battery discharge* converted in energy |\n| Instant power | V2.0.0 |  if capacity given | kW , W, ... | the power corresponding to energy variation during delta time between update |\n\n## Typical use\nTypical use is to follow the consumption of battery thanks to utility meter\n\n```yaml\n##configuration.yaml example\ntemplate:\n  - sensor:\n      - name: zoe_batterie_total_charge\n        state: \"{{ state_attr('sensor.battery_consumption_sensor_battery_level', 'total_energy_charge') }}\"\n        unit_of_measurement: 'kWh'\n        device_class: energy\n        state_class: total\n\n  - sensor:\n      - name: zoe_batterie_total_discharge\n        state: \"{{ state_attr('sensor.battery_consumption_sensor_battery_level', 'total_energy_discharge') }}\"\n        unit_of_measurement: 'kWh'\n        device_class: energy\n        state_class: total\n\n## UTILITY METER\nutility_meter:\n  zoe_batterie_total_charge_daily:\n   source: sensor.zoe_batterie_total_charge\n   cycle : daily\n  zoe_batterie_total_charge_weekly:\n   source: sensor.zoe_batterie_total_charge\n   cycle : weekly\n  zoe_batterie_total_charge_monthly:\n   source: sensor.zoe_batterie_total_charge\n   cycle : monthly\n\n  zoe_batterie_total_discharge_daily:\n   source: sensor.zoe_batterie_total_discharge\n   cycle : daily\n  zoe_batterie_total_discharge_weekly:\n   source: sensor.zoe_batterie_total_discharge\n   cycle : weekly\n  zoe_batterie_total_discharge_monthly:\n   source: sensor.zoe_batterie_total_discharge\n   cycle : monthly\n``` \n\nAnother typical use is to follow the variation of battery in statistics graph .\n```yaml\n##configuration.yaml example\ntemplate:\n  - sensor:\n      - name: zoe_batterie_variation\n        state: \"{{ state_attr('sensor.battery_consumption_sensor_battery_level', 'variation') }}\"\n        unit_of_measurement: '%'\n        device_class: battery\n        state_class: measurement\n``` \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjugla%2Fbattery_consumption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjugla%2Fbattery_consumption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjugla%2Fbattery_consumption/lists"}