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

One device discovered multiple times #2834

Open
5 tasks done
michalk-k opened this issue Dec 21, 2024 · 16 comments
Open
5 tasks done

One device discovered multiple times #2834

michalk-k opened this issue Dec 21, 2024 · 16 comments
Labels
autodiscovery bug Something isn't working

Comments

@michalk-k
Copy link

michalk-k commented Dec 21, 2024

System Health details

System Information

version core-2024.11.3
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/Prague
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
HACS Data ok
GitHub API Calls Remaining 4993
Installed Version 2.0.1
Stage running
Available Repositories 1507
Downloaded Repositories 39
Home Assistant Cloud
logged_in true
subscription_expiration January 14, 2025 at 01:00
relayer_connected true
relayer_region eu-central-1
remote_enabled true
remote_connected true
alexa_enabled false
google_enabled false
cloud_ice_servers_enabled true
remote_server eu-central-1-4.ui.nabu.casa
certificate_status ready
instance_id 3cb0d3fbab1e44f98797c10448afb4d1
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 13.1
update_channel stable
supervisor_version supervisor-2024.12.0
agent_version 1.6.0
docker_version 26.1.4
disk_total 28.6 GB
disk_used 20.0 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), Advanced SSH & Web Terminal (19.0.0), Studio Code Server (5.17.3), Mosquitto broker (6.4.1), Glances (0.21.1), Node-RED (18.1.1), Home Assistant Google Drive Backup (0.112.1), Log Viewer (0.17.1), UniFi Network Application (3.5.0), Zigbee2MQTT (1.41.0-1), SQLite Web (4.2.1), Samba share (12.3.2), Grafana (10.2.2), HassOS SSH port 22222 Configurator (0.9.3), TimescaleDB (4.2.0), MQTT Explorer (browser-1.0.1), Govee to MQTT Bridge (2024.07.13-82ddc6e9)
Dashboards
dashboards 10
resources 26
views 58
mode storage
Recorder
oldest_recorder_run December 20, 2024 at 09:28
current_recorder_run December 20, 2024 at 13:59
estimated_db_size 1610.46 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

Not sure is it PowerCalc or HA responsible for this glitch...
I found a very similar issue (if not the same), but it has been closed: #2737

Look at screenshot. It shows two devices Floor Lamp Basic and Floor Lamp Livingroom, each one listed nine times
image

It turned out 8 of them are from single device, mqtt-based govee2mqtt.
image

Reproduction steps

N/A

Debug logs

N/A

Diagnostics dump or YAML config

No response

@michalk-k michalk-k added the bug Something isn't working label Dec 21, 2024
@bramstroker
Copy link
Owner

Do you have this issue after a recent upgrade, or you had duplications longer already?

Could you please enable debug logging and share logs after restart?
You should see following in the logs multiple times.
Initiating discovery flow, unique_id=.....

@bramstroker
Copy link
Owner

In a glimpse of your screenshot I see all kind of segment lights. Segment 006, 007.
That would probably be the reason.
Because powercalc discovers devices on a per entity base, and does not expect a single device to have tens of light entities.

@bramstroker
Copy link
Owner

@michalk-k could you provide more information about this govee2mqtt device and underlying entities?
Which light entities has this one exactly? Maybe we can figure out a way to prevent discovery for all these "extra" light devices which you probably not use to actually control the light.

@michalk-k
Copy link
Author

Sure. It's

@bramstroker
Copy link
Owner

Sure. It's

... buffering. Please hold while your response loads ;-)

@michalk-k
Copy link
Author

michalk-k commented Dec 22, 2024

Yes, sure.
this Govee lamp is H6076 (Floor Lamp). It's a row of addressable leds, grouped into sections. Each section provides an option to control its color and state. The state control is somehow limited though (see screenshot in OP). Regardless that, author of Govee2MQTT mapped these sections into separate light instances.

Afaik more govee lamps exposes similar approach.

  • Outdoor Ground Lights (H7052) - 15 sections
  • TV Backlight 3 lite (6099) - 14 sections

Moreover those lamps (via Govee2Mqtt addon) provides light as well as switch entity. I don't know the reason of the switch existence yet.

BTW there are at least 3 govee integrations available. One is HA-core built-in. this one doesn't provide sections control.
Then custom integration and Govee2Mqtt add-on. both from the same author. the addon is the latests iteration if his work. Cannot say if the custom component shares 'sections' feature or not.

Do not hesitate to ask for more.

PS I write on mobile, Previously I hit save accidentally.

@bramstroker
Copy link
Owner

Hmm ok, pretty sure this profile was made with 1 light control, which controls the full array of segments.
#1955
@Sku1ly could you chime in about this?

When this profile is now used / binded to each segment it will not have correct power consumption, because than each segment will calculate power which is made the whole light, so it will be 15x too much.
Might be a recent development that segments are exposed, but this is an issue I didn't forsee. Or only the MQTT integration which does this.

Need to think about a resolution.

@bramstroker
Copy link
Owner

It won't be an easy one though.
I suggest I add some condition in code now (temporarily) where we skip discovery when we are dealing with these sections entities for now, as the current situation is not good and will cause wrong power sensors for users. Until I implement some solution to support this case.
Could you share the list of entities, how there are exactly named for this Govee device in HA?

@michalk-k
Copy link
Author

michalk-k commented Dec 22, 2024

They are suffixed by _segment_xxx

image

Here is the main light to compare:
image

Maybe instead of using textual comparison of entity name, it would be better (if we can choose the lesser evil) to check features. Take a look at the screenshot below. Segments have ON/OFF icons instead of switch icons. Doesn't it indicate that there is no feedback about the current state? Then, it could be definitively used since it does not make sense to track such an entity (You can see the last segment turned on with violet color, but it definitively doesn't reflect reality)

image

@bramstroker
Copy link
Owner

I'm not sure how I can see that in the data (the difference in the behaviour of the toggle).
Could you have a look into config/.storage/core.entity_registry?
And lookup JSON for both the main light, and Segment 001.

How does the main light behave? When you toggle it does it enable all segments or does it only turn on the certain segments which were enabled before?

@michalk-k
Copy link
Author

Here are jsons
for main light:

{"aliases":[],"area_id":null,"categories":{},"capabilities":{"min_color_temp_kelvin":2000,"max_color_temp_kelvin":9009,"min_mireds":111,"max_mireds":500,"effect_list":["","Accumulation","ARRAKIS","Aurora","Birthday","Blossom","Bouncing Ball","Bubble","Candy","Carnival","Cheerful","Cherry blossoms","Christmas","Downpour","Dreamland","Dreamlike","Electro Dance","Father's Day","Fight","Fire","Fireworks","Forest","Game","Glacier","Halloween","Heartbeat","Journey of Flowers","Karst Cave","Lake","Leisure","Leisurely","Light","Meteor","Morning","Mother's Day","Movie","Music: Bounce","Music: Calm","Music: CandyCrush","Music: Dynamic","Music: Energic","Music: Fusion","Music: Hopping","Music: Luminous","Music: Separation","Music: Skittles","Music: Strike","Music: Torch","Music: Vibrate","Night","Night Light","Party","Profound","Rainbow","Rainbow-A","Rainbow-B","Release","Ripple","Romantic","Rush","Rustling leaves","SPICE","Stacking","Study","Sunrise","Sunset","Sweet","Swing","Technology","Tenderness","The Piano","Tunnel","Valentine's Day","Volcano","Warm","Wave","Work"],"supported_color_modes":["color_temp","rgb"]},"config_entry_id":"60ce6d798552456d8abb9f4d5b9bb9f8","created_at":"2024-12-06T09:59:56.100269+00:00","device_class":null,"device_id":"e4be5b1536edd04751e0fd6166b36276","disabled_by":null,"entity_category":null,"entity_id":"light.floor_lamp_livingroom","hidden_by":null,"icon":null,"id":"5f24ed16c5fabc8041a94bae482f4b61","has_entity_name":true,"labels":[],"modified_at":"2024-12-06T09:59:56.104809+00:00","name":null,"options":{"conversation":{"should_expose":true}},"original_device_class":null,"original_icon":"mdi:floor-lamp","original_name":null,"platform":"mqtt","supported_features":44,"translation_key":null,"unique_id":"gv2mqtt-F23DD0C844866B65","previous_unique_id":null,"unit_of_measurement":null}

for its segment

{"aliases":[],"area_id":null,"categories":{},"capabilities":{"effect_list":null,"supported_color_modes":["rgb"]},"config_entry_id":"60ce6d798552456d8abb9f4d5b9bb9f8","created_at":"2024-12-06T09:59:56.505452+00:00","device_class":null,"device_id":"e4be5b1536edd04751e0fd6166b36276","disabled_by":null,"entity_category":null,"entity_id":"light.floor_lamp_livingroom_segment_001","hidden_by":null,"icon":null,"id":"f9608692b3dde891f59f87055f817eea","has_entity_name":true,"labels":[],"modified_at":"2024-12-06T09:59:56.508627+00:00","name":null,"options":{"conversation":{"should_expose":true}},"original_device_class":null,"original_icon":null,"original_name":"Segment 001","platform":"mqtt","supported_features":44,"translation_key":null,"unique_id":"gv2mqtt-F23DD0C844866B65-0","previous_unique_id":null,"unit_of_measurement":null}

tbh cannot see anything 100% useful :(
Maybe I would use unique_id rather than entity name...

@michalk-k
Copy link
Author

speaking about turning on sections. they cannot be turned on with main light turned off.

What makes it more unpredictable for power measurěemt is, that from govee app it's possible to turn on selected segment leaving others turned off. It seems impossible with use of the integration (you can still toggle the whole light - it doesn't change segments config set with govee app)

@bramstroker
Copy link
Owner

Segments are skipped for discovery now with: #2843
You can install master branch to test: https://docs.powercalc.nl/troubleshooting/install-master/
With this change and after restart the huge amount of discoveries you have should disappear.
Or wait until next release. Will probably be next week.

@RubenKelevra

This comment was marked as off-topic.

@bramstroker
Copy link
Owner

bramstroker commented Dec 28, 2024

@RubenKelevra hmm I see.
It's because for power_meter device type Powercalc considers sensor.* entities.
This device has 4 different sensor entities, so that's why powercalc discovers 4 times now.
Not a quick fix unfortunately for now.

I have just started working on a new feature so we can set a discovery_type in model.json to specify how the profile must be discovered. Can be either device or entity.
So that would be a perfect fit for this profile and to fix this issue.

However needs refactoring on a lot of places, so it's not done yet. Might be done in a few days.

@RubenKelevra

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodiscovery bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants