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

Name does not update in homebridge #76

Closed
smulle48 opened this issue Feb 23, 2021 · 11 comments
Closed

Name does not update in homebridge #76

smulle48 opened this issue Feb 23, 2021 · 11 comments

Comments

@smulle48
Copy link

smulle48 commented Feb 23, 2021

Hi

I don't know if the problem is in this plugin.

The problem is that if I have homebridge running while adding a new item in z2m, the friendly name does not update in homebridge and in the Home app.

As you can see in the screenshots, I have added a bulb in my daughters room. After inclusion, I have changed the name in z2m, but as homebridge was running while including the bulb, the IEEE address was used as the name. As you can see in homebridge, the name is indeed changed, but not used. Even if I manually change the name in homebridge, it does not change in the Home app and the only way to make it change (except to manually change it) is to reset homebridge or make sure homebridge is not running while including devices.

Skærmbillede 2021-02-23 kl  13 00 34
Skærmbillede 2021-02-23 kl  13 00 16
Skærmbillede 2021-02-23 kl  13 10 07

@itavero
Copy link
Owner

itavero commented Feb 23, 2021

Updating the display name in HomeKit automatically doesn't appear to be possible (gave it a few attempts in the code, but without any luck). Personally I also don't want/need this, as my friendly names in Zigbee2MQTT also have some stuff in there to identify the type of device and location, but I don't need that in the name for HomeKit.

You can ofcourse still rename it in the Home app itself.

@smulle48
Copy link
Author

Updating the display name in HomeKit automatically doesn't appear to be possible (gave it a few attempts in the code, but without any luck). Personally I also don't want/need this, as my friendly names in Zigbee2MQTT also have some stuff in there to identify the type of device and location, but I don't need that in the name for HomeKit.

You can ofcourse still rename it in the Home app itself.

When I used deCONZ in Jeedom with their homebridge plugin, it updated the name straight away

@itavero
Copy link
Owner

itavero commented Feb 23, 2021

Can you maybe add a link to that plugin here?
I'll see if I can peek at the code and add an option to enable this functionality (as mentioned, personally I do not want this to happen).

@smulle48
Copy link
Author

Can you maybe add a link to that plugin here?

I'll see if I can peek at the code and add an option to enable this functionality (as mentioned, personally I do not want this to happen).

The problem with Jeedom is that most of the plugins are paid plugins so they are on some private repo or something, but I think this is the plug-in :-)

https://github.com/NebzHB/homebridge-jeedom

Maybe it could be as option (turned off by default)

Just added all the devices in the house, just to realise that I had no idea which device was in which room :-)

It's a real pain in the a** to rename 100+ devices :-)

@itavero
Copy link
Owner

itavero commented Feb 23, 2021

As you can tell in your screenshot of Homebridge Config UI X, the name for the accessory is actually what you expect (a bit further down in the table).
However, the name for the service is not. I think this is what needs to be done, to get the behavior you are requesting.
The Jeedom plugin is partially with French comments, but a quick glance at it, suggests that this is also what they are doing.

Currently the service uses the friendly name up on creation (plus some additional info in some specific cases).
However, the name of the service should probably not be set explicitly by the plugin, unless there are multiple endpoints or for instance when different ServiceHandlers can implement the same service (i.e. water leak vs gas leak). I think/hope that HomeKit will automagically use the name of the accessory the service belongs to in that case, but I'm not 100% sure.

@smulle48 Just wondering, if you restart Homebridge, do you still see the incorrect names?
I might be able to make it in such a way that restarting Homebridge at least updates the names of the services. Not the best solution maybe, but it does look like it is the easiest to implement.

@smulle48
Copy link
Author

As you can tell in your screenshot of Homebridge Config UI X, the name for the accessory is actually what you expect (a bit further down in the table).

However, the name for the service is not. I think this is what needs to be done, to get the behavior you are requesting.

The Jeedom plugin is partially with French comments, but a quick glance at it, suggests that this is also what they are doing.

Currently the service uses the friendly name up on creation (plus some additional info in some specific cases).

However, the name of the service should probably not be set explicitly by the plugin, unless there are multiple endpoints or for instance when different ServiceHandlers can implement the same service (i.e. water leak vs gas leak). I think/hope that HomeKit will automagically use the name of the accessory the service belongs to in that case, but I'm not 100% sure.

@smulle48 Just wondering, if you restart Homebridge, do you still see the incorrect names?

I might be able to make it in such a way that restarting Homebridge at least updates the names of the services. Not the best solution maybe, but it does look like it is the easiest to implement.

The screenshots are with homebridge running, after I have renamed it in z2m.

In the home app, it's also using the ieee as name :-(

Yes, my first thought was that I could just restart homebridge, but that did not change anything.

But a cache reset (they don't recommend it) fixes the names.

Now that I know the "limitations" I just shut down homebridge while including, but sometimes I forget it :-)

If it's just added as an extra feature you have to enable manually, is totally fine with me :-) (ie. enable to update names at reboot)

@itavero
Copy link
Owner

itavero commented Feb 23, 2021

I'll have a look in the coming weeks if I can make a "fix" for this.

PS: Just to be clear, I meant that your screenshot shows the correct name for the accessory, but "unfortunately" Home.app shows the name of the service and not the accessory as indicated before.
image

@smulle48
Copy link
Author

No worries 😉

Now that I know it's not due to a bug in you nice plugin.

Yes, after changing the name in z2m, name is changed, but the name in the top is what's used in the home app

@itavero
Copy link
Owner

itavero commented Mar 5, 2021

Another developer on the Homebridge Discord mentioned that someone reported a bug that their plugin always overwrites the name in Homebridge.
It's more or less the opposite of this, but it did gave me some insight on how to implement this.

Currently for the Accessory I actively set the name and for the services I only set it on creation.
Instead I should at a "get" callback for the Name characteristic so it can always return an up to date default name when HomeKit requests it or the Configured Name if set, similar to what is done in this plugin.

I'll try to have a go at implementing this when I have time.

@itavero
Copy link
Owner

itavero commented Mar 7, 2021

Ignore the previous comment. I don't have to look at the Configured Name.

I think I've fixed it now by explicitly updating the Name characteristic of all services (based on the friendly_name).
I've only tested it on my development environment, but it does seem to work (and to not overwrite the name if it has been reconfigured from the Home app.

The Homebridge Config UI X overview updates "immediately" (after refreshing the page), but for the Home app to pick up the change it seems that I have to restart Homebridge.
I think that's a minor issue and would still help a lot for users in the same situation as @smulle48.

I'm going to do a bit more testing 😉

itavero added a commit that referenced this issue Mar 8, 2021
* Update Service Name if friendly_name is updated. (see #76)

* Split up updateDeviceInformation into several functions to increase readability and reduce complexity.
@itavero
Copy link
Owner

itavero commented Mar 8, 2021

Version 1.1.3 has just been released which should fix this issue. As mentioned, it might be needed to restart Homebridge once for the names to also update on the iDevice.

Closing this issue for now, as I believe it is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants