bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
963 stars 255 forks source link

Powercalc Group shows wrong Power Sensors / (counts Device Power instead of Power) #2185

Closed ChuckNorris9939 closed 6 months ago

ChuckNorris9939 commented 6 months ago

System Health details

System Information

version core-2024.4.0
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.20-haos
arch x86_64
timezone Europe/Berlin
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 | 1401 Downloaded Repositories | 63 HACS Data | ok
AccuWeather can_reach_server | ok -- | -- remaining_requests | 41
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 1. Januar 2018 um 01:00 relayer_connected | false relayer_region | null remote_enabled | false remote_connected | false alexa_enabled | true google_enabled | true remote_server | null certificate_status | null instance_id | c936bf03d0884bf6a86c7b610dc1677b can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.03.1 agent_version | 1.6.0 docker_version | 24.0.7 disk_total | 30.8 GB disk_used | 17.3 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Mosquitto broker (6.4.0), Zigbee2MQTT (1.36.1-1), Studio Code Server (5.15.0), Let's Encrypt (5.0.15), Terminal & SSH (9.10.0), ZeroTier One (0.18.0), ledfx (d7e3146), Home Assistant Google Drive Backup (0.105.2), Node-RED (17.0.11), RPC Shutdown (2.4), AirCast (4.2.1), Glances (0.21.1), Log Viewer (0.17.0), Portainer (2.0.0), ESPHome (2022.3.1), Samba share (12.3.1), AirSonos (4.2.1), ESPHome (2024.3.1), EMQX (0.5.0), SQLite Web (4.1.2), Epic Games Free (debian-2024-03-17-2), wgeasy (12), File editor (5.8.0)
Dashboards dashboards | 4 -- | -- resources | 32 views | 13 mode | storage
Recorder oldest_recorder_run | 29. März 2024 um 17:05 -- | -- current_recorder_run | 4. April 2024 um 22:02 estimated_db_size | 574.86 MiB database_engine | sqlite database_version | 3.44.2
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

Severel Smart Plugs (Nous A1T, PlusPlugS), which are added through discovery in the GUI do not work correctly when using then in a Powercalc Group. They all Have Device Power Sensor, also when enabling Utilitymeter afterwards. When i create a Group with theses Powercalc Sensors they only count the "Device Power" not the "Power". Using self created virtual sensors which dont have Device Power it works flawlessly.

Reproduction steps

  1. Add Shelly PlusPlugS from Autodiscovery
  2. Create Powercalc Group "All Power" over Integrations GUI
  3. Add Shelly "PlusPlugS 4" to powercalc sensors, leave everything else default and create the Group.
  4. only sensor.power_all_power/ Watt sensor gets created but shows only the Device Power of 1,1W
  5. Added a second powercalc sensor Tasmota NOUS A1T to Group "All Power"
  6. Now the other kWh Sensors appeard. From the Tasmota device also only the Device Power is added to sensor.power_all_power ...

Debug logs

https://pastebin.com/h7506SDv

Diagnostics dump or YAML config

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2024.4.0", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.12.2", "docker": true, "arch": "x86_64", "timezone": "Europe/Berlin", "os_name": "Linux", "os_version": "6.6.20-haos", "supervisor": "2024.03.1", "host_os": "Home Assistant OS 12.1", "docker_version": "24.0.7", "chassis": "vm", "run_as_root": true }, "custom_components": { "variable": { "version": "3.4.2", "requirements": [ "iso4217==1.11.20220401" ] }, "tuya_local": { "version": "2024.3.2", "requirements": [ "tinytuya==1.13.2" ] }, "virtual": { "version": "0.8.0.1", "requirements": [] }, "tuya_v2": { "version": "1.5.0", "requirements": [ "tuya-iot-py-sdk==0.4.1" ] }, "localtuya": { "version": "5.2.1", "requirements": [] }, "better_thermostat": { "version": "1.4.0", "requirements": [] }, "pyscript": { "version": "1.5.0", "requirements": [ "croniter==1.3.8", "watchdog==2.3.1" ] }, "truenas": { "version": "0.0.0", "requirements": [] }, "spotcast": { "version": "v3.6.30", "requirements": [] }, "spook": { "version": "2.2.4", "requirements": [] }, "uptime_kuma": { "version": "2.1.0", "requirements": [ "pyuptimekuma-hass" ] }, "climate_group": { "version": "0.4.2", "requirements": [] }, "alexa_media": { "version": "4.9.2", "requirements": [ "alexapy==1.27.10", "packaging>=20.3", "wrapt>=1.14.0" ] }, "bosch": { "version": "0.25.0", "requirements": [ "bosch-thermostat-client==v0.25.0" ] }, "powercalc": { "version": "v1.11.4", "requirements": [ "numpy>=1.21.1" ] }, "alarmo": { "version": "v1.9.15", "requirements": [] }, "nodered": { "version": "3.1.3", "requirements": [] }, "openmediavault": { "version": "0.0.0", "requirements": [] }, "o365": { "version": "v4.7.0", "requirements": [ "O365==2.0.34", "BeautifulSoup4>=4.10.0" ] }, "sonoff": { "version": "3.6.0", "requirements": [ "pycryptodome>=3.6.6" ] }, "switch_manager": { "version": "1.3.3", "requirements": [] }, "battery_notes": { "version": "2.2.5", "requirements": [] }, "bosch_shc": { "version": "0.4.88", "requirements": [ "boschshcpy==0.2.91" ] }, "ui_lovelace_minimalist": { "version": "v1.3.9", "requirements": [ "aiofiles==0.8.0", "aiogithubapi>=22.2.4" ] }, "hacs": { "version": "1.34.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "dwains_dashboard": { "version": "3.6.0", "requirements": [] }, "sleep_as_android": { "version": "2.3.0", "requirements": [ "pyhaversion" ] } }, "integration_manifest": { "after_dependencies": [ "integration", "utility_meter" ], "codeowners": [ "@bramstroker" ], "config_flow": true, "dependencies": [ "light", "group", "template", "select", "utility_meter" ], "documentation": "https://github.com/bramstroker/homeassistant-powercalc", "domain": "powercalc", "iot_class": "local_polling", "issue_tracker": "https://github.com/bramstroker/homeassistant-powercalc/issues", "name": "Powercalc", "requirements": [ "numpy>=1.21.1" ], "version": "v1.11.4", "is_built_in": false }, "data": { "entry": { "entry_id": "25569d91b6b50cda79c0b7fad79d66ad", "version": 2, "minor_version": 1, "domain": "powercalc", "title": "PlusPlugS 4", "data": { "entity_id": "switch.plug_4", "manufacturer": "shelly", "model": "shelly plus plug s", "unique_id": "pc_E465B8B5B2A8-switch:0", "sensor_type": "virtual_power", "name": "PlusPlugS 4", "_power_entity": "sensor.plusplugs_4_device_power", "_energy_entity": "sensor.plusplugs_4_device_energy" }, "options": {}, "pref_disable_new_entities": false, "pref_disable_polling": false, "source": "integration_discovery", "unique_id": "pc_E465B8B5B2A8-switch:0", "disabled_by": null } } }

bramstroker commented 6 months ago

This is actually working as expected. The discovered smart plugs only provide a virtual power sensor for the self usage of the smart plug. They all consume a littlebit of energy, and Powercalc creates a power and energy sensor to get insights in these. These are called "Device power" by convention. Entities for the actual power used by the connected appliance are already applied by the integration providing the smart plug.

To also include the existing power and energy sensors in your group (not the virtual "device power" ones) you can add the in Additional power sensors and Additional energy sensors options.

Hope this helps and clarifies things up for you.

ChuckNorris9939 commented 6 months ago

Okay Thanks. then I guess I just use the Additional sensors for the non virtual Plugs..

My thought was, when I enable Utility Meter after adding the Shelly Plug through discovey dont I have Powercalc power sensor then? image

Does this not work because the Shelly Integration power sensor still exist in Background?

bramstroker commented 6 months ago

When you toggle utility meter for the "discovered" shelly plug profile, it only applies to the virtual power and energy sensor created by powercalc. As that whole GUI configuration entry is purely for the self usage / device power of the smart plug.

When you also would like to create the utility meters for the existing power and energy sensors provided by the smart plug itself you can use the "Real power" option, see here: https://homeassistant-powercalc.readthedocs.io/en/latest/sensor-types/real-power-sensor.html. When you've done that you can also add it as a member sensor to the group, and you don't have to use Additional power sensors and Additional energy sensors options in that case.

ChuckNorris9939 commented 6 months ago
I recreated 2 Sensors in GUI using Energy from real power sensor. One with utility meter enabled and one without. image image

When i create a group they both dont show up in the list of available members. I also reloaded hassio

bramstroker commented 6 months ago

By recreated you mean you removed the ones added by powercalc and created manually using "Energy from real power" option? That means you'll lose the sensors listing the self usage of the plugs, as I can also see in your screenshot. The Device power sensors are not there anymore. I meant to say in my comment to add the "Energy from real power" additionally to the existing sensors from powercalc library. But if you are not interested in the self consumption of the plugs you can of course remove them.

You mean they are not selectable here?

Screenshot 2024-04-05 at 13 08 50
ChuckNorris9939 commented 6 months ago

By recreated you mean you removed the ones added by powercalc and created manually using "Energy from real power" option?

Yes. I removed them and used this one: image

I meant to say in my comment to add the "Energy from real power" additionally to the existing sensors from powercalc library.

Then i got one from library and one from real power Then I can select the one from library but this does not change behaivour. or did I get it wrong?

You mean they are not selectable here?

Correct, the Energy from real power sensor ones from the screenshot dont show up there.

bramstroker commented 6 months ago

Could you share the diagnostics from the two integration entries you added?

Screenshot 2024-04-05 at 15 26 07

And screenshot of what you see in the Member entities dropdown?

That might help finding the issue.

ChuckNorris9939 commented 6 months ago

Sure Plug 1: config_entry-powercalc-b911aa47e27e28bf6abee4b0828c60f9.json

Plug 4: config_entry-powercalc-a26ffec2a83a8a9f923ba3ca27a94a2d.json

image

PlusPlugS4 is the discovered one / from library : config_entry-powercalc-310939cde88624e10fadf695cadb5270.json

bramstroker commented 6 months ago

I have looked into the code and only powercalc entries created with "Virtual power (manual or library)" are listed here. I'll have a look if I can also add the "Energy from real power" to be selected. Will need to do some testing and verification. Will come back on it soon.

bramstroker commented 6 months ago

Fixed with #2187. You can install the master branch with HACS to test. Or wait until next release, but that will probably be next weekend.

ChuckNorris9939 commented 6 months ago

Great 👍 I'm gonna test with next release update.