Homekit binding: Adding new items results in setting rooms in Home app

Tags: #<Tag:0x00007f6176c999e0> #<Tag:0x00007f6176c998a0> #<Tag:0x00007f6176c997b0>

Hi!

Whenever I add a new item to my OH setup (2.5.5 Release Build) and make it available to the HomeKit binding by setting the correct tag, I need to set the room location again of all items in the Home app again.
Is there a technical reason for this or do I need to live with this? :slight_smile:
Thanks for any answer

I think it’s part of it having to restart the homekit binding… It was one of the reasons I took control of homekit away from opehab and pushed mine into homebridge (which has a convienient openhab plugin). It means that if I restart openhab or add an item, then homekit is not affected generally. I can also operate in homebridge without affecting openhab.

Hi Peter

this was fixed in 2.5.6-Snapshot. please try it out.

/eugen

@yfre sorry for the noob reply, but the OH snapshot? or the snapshot of the binding?

@pverhoye the snapshot of binding
you can find the latest snapshot here
https://openhab.jfrog.io/openhab/libs-pullrequest-local/org/openhab/addons/bundles/org.openhab.io.homekit/2.5.6-SNAPSHOT/org.openhab.io.homekit-2.5.6-SNAPSHOT.jar

and update it from karaf console with bundle:update

@yfre: sorry for relying so late. Yep, the snapshot works here. Thanks!

1 Like

@yfre hi! Do you know the PR of this fix? Because in the latest update, this fix was still not included but I don’t find the PR in GitHub

@pverhoye do you still have issue with lost accessories?

there are relevant PRs


both are merged. so, if you upgrade to 2.5.6 released in the last day, then you should have both fixes. please let me know if you still experience issues

Well, I still have an issue where, if there is an error in the .items file (for example a } is not closed), and the fix it, all rooms are reset to Default Room again in homekit

ok. actually it should only reset the room for items which had an error in the config.
the process is like this:

  • when you save .items, openhab notify homemkit binding about change items. if there is mistake in config then homekit will get notification that that item was deleted
  • homekit binding notify home app about configuration change
  • home app requests a new list of accessories (accessories with an error will miss no that list)
  • home app compare the new list with internal db of accessories and add/delete accessories which are new or were removed

important, if you rename accessory then home app consider it as a new accessory.

Well, maybe there is something wrong still when the parsing of the file fails.
This is my situation before the deliberate error:


(look at the top row)

In my .items file, the last line I change to this:

Rollershutter ScreenLivingZuid “Klein raam” (V0_Living, gRollershutters) {channel=“qbus:rollershutter:CTD00XXX:364:rollershutter”, homekit=“WindowCovering”

So I remove the ‘}’ at the end of the line

I get this:

Then I correct the error and get this:


(all on the top line have reverted to the default room again)

I also tried updating the bundle as you described above before you said it was merged but the problem was the same.

However what does work is when I add an item or remove an item. Then all the rooms stay as I configured them.

Hope this helps.

ok. this is expected behaviour,
due an error in .items, none of items can be read correctly. basically, openhab reports - no correct items found. (ScreenLivingZuid is probably one of the first items in .items file). homekit binding reports to home app - all accessories are deleted. if home app requests the list of accessories then binding does not know what to reply. it does not keep the list of old accessories and the new one is empty due the error.

not sure how we could prevent this and protect from home app reset.
the only idea i have is to stop homekit binding, do all changes to .items, make sure all items are configured correctly, and then start homekit binding.

probably we could h

I don’t know anything about the inner workings of OH but maybe something like this?

file gets changed
backup HomeKit data
check if config file is well formed
if NOK {
-> log error and restore HomeKit data backup
}
if OK {
-> process items item per item
-> if item OK
–> replace current entry in HomeKit config if exists or create new item in HomeKit config
-> if item NOK
–> log error
–> don’t add item
}
set HomeKit config and start binding

@pverhoye yes, agree, this would the right approach. i.e. make processing of items configuration more robust, e.g. skip the line with the syntax error and continue with remaining configuration. currently, depending on the type of the syntax error it would mark the complete configuration as broken and hence remove all items.
making processing of the configure files more robust is not as easy as might sounds. and must be done in openhab core and not in homekit binding. maybe it will be improve openhab 3.
until then i can recommend to split bigger item configuration files in several small files. in this case you would lose only part of items in case of the syntax error.

1 Like

I figured as much :slight_smile:
Anyway thanks for your help!!