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

Accessory with two services not handled correctly #426

Closed
LaborEtArs opened this issue Dec 14, 2019 · 5 comments
Closed

Accessory with two services not handled correctly #426

LaborEtArs opened this issue Dec 14, 2019 · 5 comments
Labels

Comments

@LaborEtArs
Copy link

Describe The Bug:
Added an accessory with two 'Outlet' services ('Out' and 'Out2'). Used cflurin's homebridge-mqtt to do so. The accessory displays correctly on iPhone 'Home' app (one button, that opens to a window showing two switches to toggle the outlets). When toggling any of the switches, the state is correctly transferred to the HW accessory (which is living on an ESP8266 controller driving a MQTT client).
When changing the state of any service inside the HW accessory the new state is also transferred to the Home app correctly. So everything seems to be OK on the foundation level.
The BUG: The accessory is shown in the homebridge-config-ui-x website as two separate buttons. The first works as expected, on state change (by toggling from the website or from the HW accessory) the the display state is updated correctly (On/Off). The second DOESN'T gets updated; neither when toggling the button in the website, nor when toggling the state form HW accessory side. Only a website refresh updates the button to the correct state. Im using Safari Version 13.0.4 on a Mac.

To Reproduce:
Create an accessory with two 'Outlet' services

Expected behavior:
The button for the second service should display the current state of the second accessory correctly.

Logs:
How to create logs; found nothing in the 'Contribution Guidelines'...

Show the Homebridge / Homebridge Config UI X logs here.

Homebridge Config:

{
            "platform": "config",
            "name": "Config",
            "port": 8080,
            "sudo": true,
            "restart": "sudo -n systemctl restart homebridge",
            "log": {
                "method": "systemd",
                "service": "homebridge"
            }
        },

Screenshots:
Bildschirmfoto 2019-12-14 um 18 42 05

Environment:

  • Node.js Version: v11.15.0
  • NPM Version: 6.13.0
  • Homebridge Version: homebridge API version: 2.4
  • Homebridge Config UI X Version: homebridge-config-ui-x v4.6.3
  • Operating System: Raspberry
  • Process Supervisor: Systemd
@LaborEtArs LaborEtArs added the bug label Dec 14, 2019
@oznu
Copy link
Member

oznu commented Dec 14, 2019

Thanks for the report @LaborEtArs, I'll investigate this.

@mkellsy
Copy link
Contributor

mkellsy commented Dec 16, 2019

This is just a thought.
I modify the "aid" for each accessory, and add a .1, .2, etc to the "aid".

For example a nest thermostat has multiple accessories, and they all have an "aid" of 54.
Then the JSON will have 3 accessories
54.1 -> thermostat
54.2 -> Fan
54.3 -> Home/Away

Then to get the actual "aid" i just run Math.floor(aid);

@LaborEtArs
Copy link
Author

According to the HAP specification, an accessory id, as well as the service id, should be a number in the range of [1, 18446744073709551615] (see extract below). @mkells: Are your modified ids visible to the Homekit (HAP) side of 'Homebridge', or 'only' used internaly?

From 'HomeKit Accessory Protocol Specification R2':

2.6.1 Instance IDs
instance IDs are numbers with a range of [1, 18446744073709551615] for IP accessories (see ”7.4.4.2 Instance IDs” (page 122) for BLE accessories). These numbers are used to uniquely identify HAP accessory objects within an HAP accessory server, or uniquely identify services, and characteristics within an HAP accessory object. The instance ID for each object must be unique for the lifetime of the server/client pairing.
2.6.1.1 Accessory Instance IDs
Accessory instance IDs, aid, are assigned from the same number pool that is global across entire HAP accessory server. For example, if the first Accessory object has an instance ID of “1”, then no other Accessory object can have an instance ID of “1” within the Accessory Server.
2.6.1.2 Service and Characteristic Instance IDs
Service and Characteristic instance IDs, iid, are assigned from the same number pool that is unique within each Ac- cessory object. For example, if the first Service object has an instance ID of “1”, then no other Service or Characteristic objects can have an instance ID of “1” within the parent Accessory object. The Accessory Information service must have a service instance ID of 1.

@oznu
Copy link
Member

oznu commented Dec 17, 2019

Hi @LaborEtArs,

Once again, thanks for reporting this. I was able to replicate this issue and have fixed it in v4.6.6.

@oznu oznu closed this as completed Dec 17, 2019
@LaborEtArs
Copy link
Author

THX :-) Good job!

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

No branches or pull requests

3 participants