bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
1.02k stars 262 forks source link

wrong energy when using template #2244

Closed ewonais closed 4 months ago

ewonais commented 6 months ago

System Health details

System Information

version core-2024.5.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.28-haos-raspi
arch aarch64
timezone Europe/Stockholm
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1399 Downloaded Repositories | 10 HACS Data | ok
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 26 December 2024 at 01:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server | eu-central-1-14.ui.nabu.casa certificate_status | ready instance_id | 76591d32c3ca4a49aadcdb128fcefd44 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.3 -- | -- update_channel | stable supervisor_version | supervisor-2024.05.1 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 57.8 GB disk_used | 20.8 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | File editor (5.8.0), Terminal & SSH (9.14.0), Mosquitto broker (6.4.0), Double Take (1.13.1), DeepStack (2021.09.1)
Dashboards dashboards | 2 -- | -- resources | 1 views | 1 mode | storage
Recorder oldest_recorder_run | 2 May 2024 at 06:58 -- | -- current_recorder_run | 13 May 2024 at 17:48 estimated_db_size | 282.36 MiB database_engine | sqlite database_version | 3.44.2

Checklist

Describe the issue

I tried to use a template to make the graph mor accurate fore a sensor. the result was werry incorect. Then i locked at tge power graph, it locked correct but the graph for energy was not correct. For testing i created a sensor drawing 50 w every odd hour: {{ now().hour % 2 * 50}} correct power, 0 for even hours and 50 for odds: image

wrong energy: image 50*5=0.250kwh, not 0,425

Reproduction steps

  1. add a sensor for daily energy in the GUI
  2. set units to "w" and add a templare, for exampel: {{ now().hour % 2 * 50}}
  3. let it run for a while
  4. lock at the graphs, the one for power is corect but energy is wrong

Debug logs

github dont let me add the file here and it was to long to paste here.
https://pastebin.com/zS0R3Kjv

Diagnostics dump or YAML config

config_entry-powercalc-73d24a8d01c1edc366d61f879c357e70.json

ewonais commented 6 months ago

workaround: use a template helper or any other helper and than create: image

everything locks ok, but i only did a short test

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 5 days with no activity.