home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.65k stars 30.41k forks source link

Fully Kiosk Browser Merging Entities #77722

Closed reotto613 closed 1 year ago

reotto613 commented 2 years ago

The problem

I have 5 tablets which I used to have under the Fully Kiosk Browser via HACS integration for a long time with no issues.

With the release of 2022.9 I removed them all from under HACS and put them under the official integration.

The problem is my system is confusing or merging 2 of the tablets for some reason(see pics), and putting the entities for both under each other. It still shows 26 entities when I bring up that individual tablet, but when you go into it then it shows 52 (26 for each tablet)

Here is what it looks like when I initially go to the Integrations page. FKBIntegrations

When I open up the Basement SE Tablet I get this look: FKBBasementSE

When I open the First Floor E Tablet I get this: FKBFirstFloorE

When I open either tablet I get this (note since I added the First Floor E tablet last that it updates both to show the exact same name and location)-In this case I actually clicked on the Basement SE tablet, but it shows the name and location as First Floor E: FKBBasementSEDevice

Now since you see both the media player entity for the tablets I will click on each to show you the entity name: FKBBasementSEDevice1

Here is the other media player entity from the screen shot above: FKBBasementSEDevice2

What version of Home Assistant Core has the issue?

2022.9

What was the last working version of Home Assistant Core?

2022.8.7

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Fully Kiosk Browser

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/fully_kiosk

Diagnostics information

These are the downloads of both diagnostic files under the Bedroom SE Tablet: fully_kiosk-32b6cc70da6d6a12ab734e7d8f1bace8-Basement SE Bedroom Tablet-c11835eb234432c5b570ee2326e7553d.json.txt

fully_kiosk-e1e5f613865459c826b8d3d8dca46690-Basement SE Bedroom Tablet-c11835eb234432c5b570ee2326e7553d.json.txt

These are the downloads of both of the diagnostic files under the First Floor E Tablet: fully_kiosk-32b6cc70da6d6a12ab734e7d8f1bace8-Basement SE Bedroom Tablet-c11835eb234432c5b570ee2326e7553d.json.txt

fully_kiosk-e1e5f613865459c826b8d3d8dca46690-Basement SE Bedroom Tablet-c11835eb234432c5b570ee2326e7553d.json.txt

Example YAML snippet

N/A

Anything in the logs that might be useful for us?

No response

Additional information

I have deleted all the tablets to start over, same issue.

I have renamed all the entities which doesn't help.

If I change the overall device name and approve changing the entity names then it changes then on the device screen, but it doesn't change all the entity names.

probot-home-assistant[bot] commented 2 years ago

fully_kiosk documentation fully_kiosk source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @cgarwood, mind taking a look at this issue as it has been labeled with an integration (fully_kiosk) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

cgarwood commented 2 years ago

To make sure I'm following correctly, the Integrations page correctly shows "1 device with 26 entities" for each tablet, but then when you click on the device it shows entities from both tablets?

Could you dig into your <config dir>/.storage/core.entity_registry file, find 2 of the problem entities (like both media_player entities or both Screensaver switch entities, etc) and post the device_id, entity_id, config_entry_id, and unique_id for both of them?

Thanks!

reotto613 commented 2 years ago

Ok so I had restored an old backup this weekend to go back to where it worked. This morning I removed that entire integration (The HACS version of this integration), and now I am seeing 3 of the integrations being integrated. They all 3 show up as First Floor E Bedroom. Here is the code excerpt that I found from the Core Device Registry.

{ "config_entries": [ "62248c6c4c13fc430a4eb917689a4d24", "2708285dfeb3b794596f263702ebe1c0", "efd047724bfa41f9068c4d92d5c1eb1e" ], "connections": [ [ "mac", "" ] ], "identifiers": [ [ "fully_kiosk", "1921f25e-4d47897a" ], [ "fully_kiosk", "44f25f57-ec6367d2" ], [ "fully_kiosk", "dddd4d72-a1200556" ] ], "manufacturer": "samsung", "model": "SM-T290", "name": "Galaxy Tab A (8.0\", 2019)", "sw_version": "1.48.1-play", "hw_version": null, "entry_type": null, "id": "504cb5d8156c2264bc89f4abefeb1e24", "via_device_id": null, "area_id": "basement_nw_bedroom", "name_by_user": "First Floor E Bedroom Tablet", "disabled_by": null, "configuration_url": "http://10.7.96.84:2323" }

Here are the entries for the media players from all three:

{ "area_id": null, "capabilities": {}, "config_entry_id": "62248c6c4c13fc430a4eb917689a4d24", "device_class": null, "device_id": "504cb5d8156c2264bc89f4abefeb1e24", "disabled_by": null, "entity_category": null, "entity_id": "media_player.galaxy_tab_a_8_0_2019_2", "hidden_by": null, "icon": null, "id": "3e504291ed23f7b473dc59d2f2791b34", "has_entity_name": true, "name": "First Floor E Bedroom Tablet", "options": {}, "original_device_class": null, "original_icon": null, "original_name": null, "platform": "fully_kiosk", "supported_features": 135684, "unique_id": "44f25f57-ec6367d2-mediaplayer", "unit_of_measurement": null },

{ "area_id": null, "capabilities": {}, "config_entry_id": "efd047724bfa41f9068c4d92d5c1eb1e", "device_class": null, "device_id": "504cb5d8156c2264bc89f4abefeb1e24", "disabled_by": null, "entity_category": null, "entity_id": "media_player.first_floor_e_bedroom_tablet", "hidden_by": null, "icon": null, "id": "6feca81aade58ea79d885d7c8256cc4e", "has_entity_name": true, "name": null, "options": {}, "original_device_class": null, "original_icon": null, "original_name": null, "platform": "fully_kiosk", "supported_features": 135684, "unique_id": "dddd4d72-a1200556-mediaplayer", "unit_of_measurement": null },

{ "area_id": null, "capabilities": {}, "config_entry_id": "2708285dfeb3b794596f263702ebe1c0", "device_class": null, "device_id": "504cb5d8156c2264bc89f4abefeb1e24", "disabled_by": null, "entity_category": null, "entity_id": "media_player.first_floor_e_bedroom_tablet_2", "hidden_by": null, "icon": null, "id": "dd0bff4d1411b22a790b933c7ea5a373", "has_entity_name": true, "name": null, "options": {}, "original_device_class": null, "original_icon": null, "original_name": null, "platform": "fully_kiosk", "supported_features": 135684, "unique_id": "1921f25e-4d47897a-mediaplayer", "unit_of_measurement": null },

h4nnes commented 2 years ago

Same Problem here

tonysurma commented 2 years ago

Same Problem here with two tablets doubling up exactly as above and I think this is related to/aligned to #77971 as that is not pulling up names like the past and if you rename anyone integration it renames them all

cgarwood commented 2 years ago

Ah, I think I see the problem:

"connections": [
[
"mac",
""
]
],

For those of you having this problem, are you running the latest version of Fully? It looks like Fully is returning an empty string under the "Mac" field so it appears to the device registry like a single device.

reotto613 commented 2 years ago

I updated all my tablets and updated the Fully App before I posted my issue so I know I am on the latest.

tonysurma commented 2 years ago

unfortunately same here, all the latest and it was working with the non core HACS install (which I am going to later today/this weekend install again so I can reverify that setup works again.)

Thanks for looking into this

reotto613 commented 2 years ago

I will add this nugget of information. I went into the web page for FKB that allows you to operate remotely. It usually use a port of 2323. I found that the MAC address is not showing for my 3 tablets in question. I am going to try uninstalling FKB and reinstalling. I am curious if we I installed it if one of the permissions was missed. I am not sure how FKB operates if you do not give implicit consent as most of the permissions disappear after seeing them when setting it up. They do not normally show up again from what I have seen. I will try to get to that tonight, and report my results.

I will state that the HACS version always worked without a glitch, but I am not sure how they implemented the solution.

cgarwood commented 2 years ago

@reotto613 definitely interested to see if a re-install of FKB helps. Wondering if there's a common version of FKB or common hardware that is causing it to return a blank mac address.

reotto613 commented 2 years ago

@reotto613 definitely interested to see if a re-install of FKB helps. Wondering if there's a common version of FKB or common hardware that is causing it to return a blank mac address.

I reloaded a tablet tonight and the MAC address is still not coming through when I check the admin panel via port 2323. I haven't tried adding it as an integration as I assume it will have the same result without a MAC address.

reotto613 commented 2 years ago

I think I have it figured out OR how to work around it at least.

My tablet are on WiFI. If you go into Settings/Connection/WiFi then at the top should be the SSID of your current connection. Click on the gear to the right. Inside that menu choose Advanced. Under MAC address there are 2 options. Tablet MAC or Randomized MAC. My 2 working tablets were set to Randomizes MAC. My other three were set to Tablet MAC.

That Randomized MAC now shows up when accessing the tablet directly via the IP address: 2323 so I am hopeful this will work.

I am changing all 3 that were set to Tablet MAC to Randomized MAC, and then I will retry the Integrations in HA tomorrow. (Sorry everyone I need my beauty sleep).

reotto613 commented 2 years ago

I think I have it figured out OR how to work around it at least.

My tablet are on WiFI. If you go into Settings/Connection/WiFi then at the top should be the SSID of your current connection. Click on the gear to the right. Inside that menu choose Advanced. Under MAC address there are 2 options. Tablet MAC or Randomized MAC. My 2 working tablets were set to Randomizes MAC. My other three were set to Tablet MAC.

That Randomized MAC now shows up when accessing the tablet directly via the IP address: 2323 so I am hopeful this will work.

I am changing all 3 that were set to Tablet MAC to Randomized MAC, and then I will retry the Integrations in HA tomorrow. (Sorry everyone I need my beauty sleep).

All-I was able to install all 3 tablets this morning after switching them to Randomized MAC with no issues. I am not sure why the MAC is not being exposed in FKB. My assumption is that it is a security function, but I am not sure on what level. I may switch some of them back and try an ARP -a to see if I can see the MAC address. I did check my router and the MAC is visible in there so it is being passed from the device.

For this integration, I think at a minimum we should update the instructions to have people check their device and make sure FKB is showing the MAC of their device via the 2323 port. Just my input.

mheath commented 2 years ago

In my case, if my tablets are connected via wifi- and ONLY wifi - FKB is able to properly report the mac address. The problem is, all my kiosk tablets are powered with power over ethernet and also use the ethernet for network connectivity. If I have ethernet enabled, FKB won't report a mac address even if I also turn on wifi.

My FKB version is 1.48.1-play which, according to Play, is the latest version.

mheath commented 2 years ago

I can't help but wonder if using the network mac is even the right way to identify a device running FKB. In my case where I'm not using wifi, if I were to change the ethernet/usb adapter in one of my kiosk tablets, HA would assume it's a different device (assuming FKB reported the mac address correctly) when in fact it's the same FKB device with a new network adapter.

npawelek commented 1 year ago

I added a second FKB tablet this evening and ran into this issue also. Installed the latest version of FKB from the Play store and I'm running home assistant 2022.12.1.

mbillow commented 1 year ago

@cgarwood I think we should be treating MAC address as an optional field. I don't really know if it is worth digging into why some devices aren't registering it if we don't actually need it.

imo, we have two options:

  1. We just completely delete this line. This means we rely entirely on the unique device ID returned by Fully.
  2. We add some conditional logic, either:

Use a ternary for that one line:

self._attr_device_info = DeviceInfo(
    # ...
    connections={(CONNECTION_NETWORK_MAC, coordinator.data["Mac"])} if coordinator.data["Mac"] else set(),
)

Or we can break the parameters out into a dictionary and then unpack them in the call to the object init function:

device_params = {
  "identifiers": {(DOMAIN, coordinator.data["deviceID"])},
   "name": coordinator.data["deviceName"],
   # ...
}

if coordinator.data["Mac"]:
  devices_params["connections"] = {(CONNECTION_NETWORK_MAC, coordinator.data["Mac"])}

self._attr_device_info = DeviceInfo(**device_params)

This should avoid the HA device registry from combining the devices, since there won't be any matching fields between devices without MAC addresses anymore.

Each identifier and each connection is matched individually (e.g. only one connection needs to match to be considered the same device). [Device Registry Docs]

akmolina28 commented 1 year ago

For anyone waiting for this fix, I was able to work around the problem by changing my tablet to use a randomized mac and a static IP to keep the address the same. You may need to delete any existing DHCP reservations for that IP. After setting up the integration I changed back to a static mac address, then re-added the static IP in my DHCP list.