Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensor not created because of missing UUID and multiple sensor use #2684

Closed
5 tasks done
denkwolf opened this issue Nov 17, 2024 · 3 comments
Closed
5 tasks done

sensor not created because of missing UUID and multiple sensor use #2684

denkwolf opened this issue Nov 17, 2024 · 3 comments
Labels
bug Something isn't working config-flow enhancement New feature or request

Comments

@denkwolf
Copy link

System Health details

System Information

version core-2024.11.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.31-haos-raspi
arch aarch64
timezone Europe/Vienna
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
HACS Data ok
GitHub API Calls Remaining 5000
Installed Version 2.0.1
Stage running
Available Repositories 1461
Downloaded Repositories 38
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 13.2
update_channel stable
supervisor_version supervisor-2024.11.2
agent_version 1.6.0
docker_version 27.2.0
disk_total 116.8 GB
disk_used 40.7 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization
board rpi4-64
supervisor_api ok
version_api ok
installed_addons File editor (5.8.0), Terminal & SSH (9.15.0), AdGuard Home (5.1.5), Node-RED (18.1.1), Home Assistant Google Drive Backup (0.112.1), Studio Code Server (5.17.3), Mosquitto broker (6.4.1), OpenThread Border Router (2.12.0), Zigbee2MQTT (1.41.0-1), Zigbee2MQTT (1.41.0-1)
Dashboards
dashboards 7
resources 22
views 48
mode storage
Recorder
oldest_recorder_run 8. November 2024 um 20:34
current_recorder_run 16. November 2024 um 21:34
estimated_db_size 12659.57 MiB
database_engine sqlite
database_version 3.45.3

Checklist

  • I have read the FAQ to see if there is a known solution to my problem.
  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of currently previous issues..

Describe the issue

When adding a new sensor (existing sensor by a device) and you have added this sensor already in another powercalc-sensor, there is an entry created, but it fails to add additional sensors eg. for the use in an energymeter. so you get an configuration entry without additional sensors:

Einstellungen – Home Assistant 2024-11-17 18-03-14(1)

There is no hint for the error and the user is left in the dark what to do. it is stated in the logs:

2024-11-17 11:36:20.902 ERROR (MainThread) [custom_components.powercalc.sensor] sensor.energy_log_current_power_consumption_32306: **This entity has already configured a power sensor. When you want to configure it twice make sure to give it a unique_id**

solutions could be:

  • ask the user for an unique id
  • inform the user of a sensor already in use and
    -- ask the user if the system should create one or the process should be aborted
    -- generate a UUID automatically in the background
  • no info for the user, just generate a UUID in the background

i would definitly prefer an automatic generation one or the other way so the user does not have to deal with coding ...

Reproduction steps

  1. set up a sensor with a power-sensor of an existing entity
  2. try to set up another sensor with the same power-sensor of an existing entity

Debug logs

2024-11-17 11:36:20.902 ERROR (MainThread) [custom_components.powercalc.sensor] sensor.energy_log_current_power_consumption_32306: This entity has already configured a power sensor. When you want to configure it twice make sure to give it a unique_id
2024-11-17 11:36:49.564 ERROR (MainThread) [custom_components.powercalc.sensor] sensor.energy_log_current_power_consumption_32306_2: This entity has already configured a power sensor. When you want to configure it twice make sure to give it a unique_id

Diagnostics dump or YAML config

{
"home_assistant": {
"installation_type": "Home Assistant OS",
"version": "2024.11.2",
"dev": false,
"hassio": true,
"virtualenv": false,
"python_version": "3.12.4",
"docker": true,
"arch": "aarch64",
"timezone": "Europe/Vienna",
"os_name": "Linux",
"os_version": "6.6.31-haos-raspi",
"supervisor": "2024.11.2",
"host_os": "Home Assistant OS 13.2",
"docker_version": "27.2.0",
"chassis": "embedded",
"run_as_root": true
},
"custom_components": {
"powercalc": {
"documentation": "https://docs.powercalc.nl",
"version": "v1.15.4",
"requirements": [
"numpy>=1.21.1"
]
},
"hacs": {
"documentation": "https://hacs.xyz/docs/configuration/start",
"version": "2.0.1",
"requirements": [
"aiogithubapi>=22.10.1"
]
},
"midea_dehumidifier_lan": {
"documentation": "https://github.com/nbogojevic/homeassistant-midea-air-appliances-lan/blob/main/README.md",
"version": "0.9.4",
"requirements": [
"midea-beautiful-air==0.10.5"
]
},
"waste_collection_schedule": {
"documentation": "https://github.com/mampfes/hacs_waste_collection_schedule#readme",
"version": "2.4.0",
"requirements": [
"icalendar",
"recurring_ical_events",
"icalevents>=0.1.26,!=0.1.28",
"beautifulsoup4",
"lxml",
"pycryptodome"
]
}
},
"integration_manifest": {
"after_dependencies": [
"integration",
"utility_meter"
],
"codeowners": [
"bramstroker"
],
"config_flow": true,
"dependencies": [
"light",
"group",
"template",
"select",
"utility_meter"
],
"documentation": "https://docs.powercalc.nl",
"domain": "powercalc",
"iot_class": "calculated",
"issue_tracker": "https://github.com/bramstroker/homeassistant-powercalc/issues",
"name": "Powercalc",
"requirements": [
"numpy>=1.21.1"
],
"version": "v1.15.4",
"is_built_in": false,
"overwrites_built_in": false
},
"setup_times": {
"null": {
"setup": 3.5852293679490685
},
"01JAE3KA1K1PZ14FQYWKT0WFRS": {
"wait_import_platforms": -0.0002492018975317478,
"config_entry_setup": 0.02400808222591877
},
"01JAF7N2YC4D6Y11EFJ69PMY1V": {
"config_entry_setup": 0.01846133079379797
},
"01JAF7PC7HWDC28ATQFZ3E12AW": {
"config_entry_setup": 0.013555796816945076
},
"01JCV4RT42S0988XFR9PFZDGJ4": {
"config_entry_setup": 0.017215249128639698
},
"01JCKS35MYP4ZSHGB66GRPQVVF": {
"config_entry_setup": 0.21734145190566778
},
"01JB71BYHEFZG9GZ6EN810ANTC": {
"config_entry_setup": 0.21940632490441203
},
"01JCKTFAAVJ4KCY8045HNKGKSX": {
"config_entry_setup": 0.2141138301230967
},
"01JCKTKRQMED7WFF3YX71S56MP": {
"config_entry_setup": 0.15739877382293344
},
"01JCKTP4CT0EMTM20W53CZSTJT": {
"config_entry_setup": 0.10215092776343226
}
},
"data": {
"entry": {
"created_at": "2024-11-17T16:30:59.769854+00:00",
"data": {
"name": "15 WP energyconsumption",
"create_utility_meters": true,
"entity_id": "sensor.energy_log_current_power_consumption_32306",
"device": "0341dbb7c2e8bc1c6a11e32799a1cdda",
"utility_meter_types": [
"daily",
"weekly",
"monthly",
"yearly"
],
"utility_meter_tariffs": [],
"utility_meter_net_consumption": false,
"utility_meter_offset": 0.0,
"sensor_type": "real_power"
},
"discovery_keys": {},
"disabled_by": null,
"domain": "powercalc",
"entry_id": "01JCXFD65S69N0VWHNRBAQ4AS7",
"minor_version": 1,
"modified_at": "2024-11-17T16:30:59.769868+00:00",
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"title": "15 WP energyconsumption",
"unique_id": null,
"version": 4
}
}
}

@denkwolf denkwolf added the bug Something isn't working label Nov 17, 2024
@bramstroker
Copy link
Owner

Thanks for raising this issue.
I gave it a thought but I didn't see any reason why I wouldn't just generate a UUID for every config flow the user does.
Also removed unique id field from the dialog as well.

Implemented with #2708.
Will release new beta later today. Would be nice if you can give it a test run.

@bramstroker bramstroker added enhancement New feature or request config-flow labels Nov 23, 2024
@denkwolf
Copy link
Author

lookimng good - sensor was generated and the utility-meters are counting as far as i can see ... 👍

@bramstroker
Copy link
Owner

Thanks for checking

@bramstroker bramstroker mentioned this issue Dec 1, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working config-flow enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants