question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q: HAP Light Brightness behavior

See original GitHub issue

Hello, setting brightness for a Light_accessory through iOS Home app, generates two characteristic set messages “Brightness” and “On” as seen in log… Is it possible to remove/discard the second characteristic set message “On” which I think is not needed as the brightness value can fully control the accessory. Thank you!

  EventedHTTPServer [::ffff:iPhone] HTTP request: /characteristics +2s
  HAPServer [FA:3C:ED:5A:1A:1A] HAP Request: PUT /characteristics +3ms
  Accessory [Office Light] Processing characteristic set: [{"aid":1,"iid":11,"value":0},{"aid":1,"iid":10,"value":0}] +6ms
  >>>>Accessory [Office Light] Setting Characteristic "Brightness" to value 0 +3ms
  EventedHTTPServer [::ffff:appleTV] Sending HTTP event '1.11' with data: {"characteristics":[{"aid":1,"iid":11,"value":0}]} +5ms
  EventedHTTPServer [::ffff:iPhone] Muting event '1.11' notification for this connection since it originated here. +9ms
  >>>>Accessory [Office Light] Setting Characteristic "On" to value 0 +3ms
  EventedHTTPServer [::ffff:appleTV] Sending HTTP event '1.10' with data: {"characteristics":[{"aid":1,"iid":10,"value":false}]} +7ms
  EventedHTTPServer [::ffff:iPhone] Muting event '1.10' notification for this connection since it originated here. +8ms
  EventedHTTPServer [::ffff:iPhone] HTTP Response is finished +5ms

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ebaauwcommented, Dec 16, 2017

so queuing all settings events to that single light into a single request would help based on the timer value of 20ms, which assumes that all light settings characteristic events happen within that short period of time?

HomeKit (the Home app) actually sends a single message to homebridge containing multiple characteristics (run DEBUG=* homebridge -D to see these messages). The 20ms is just compute time for homebridge, breaking up this message into multiple set events, one for each characteristic.

Here’s an example log switching on a light (Living Room 1) from the Home app. The lights is connected to deCONZ and exposed to HomeKit by my homebridge-hue plugin:

  EventedHTTPServer [::ffff:192.168.xxx.xxx] HTTP request: /characteristics +17s
  HAPServer [CC:22:3D:E3:CE:30] HAP Request: PUT /characteristics +0ms
  Accessory [Homebridge - mbpr] Processing characteristic set: [{"aid":161,"iid":11,"value":45},{"aid":161,"iid":10,"value":1}] +0ms
  Accessory [Homebridge - mbpr] Setting Characteristic "Brightness" to value 45 +0ms
[2017-12-16 12:48:56] [Hue] Living Room 1: homekit brightness changed from 0% to 45%
  EventedHTTPServer [::ffff:192.168.xxx.xxx] Muting event '161.11' notification for this connection since it originated here. +1ms
  Accessory [Homebridge - mbpr] Setting Characteristic "On" to value 1 +0ms
[2017-12-16 12:48:56] [Hue] Living Room 1: homekit power changed from 0 to 1
  EventedHTTPServer [::ffff:192.168.xxx.xxx] Muting event '161.10' notification for this connection since it originated here. +0ms
  EventedHTTPServer [::ffff:192.168.xxx.xxx] HTTP Response is finished +0ms
[2017-12-16 12:48:56] [Hue] pi2: gateway request 14: put /lights/221/state {"bri":114,"on":true}
[2017-12-16 12:48:56] [Hue] Living Room 1: state changed event
[2017-12-16 12:48:56] [Hue] Living Room 1: event: light on changed from false to true
[2017-12-16 12:48:56] [Hue] pi2: gateway request 14: ok
[2017-12-16 12:48:56] [Hue] Living Room 1: state changed event

The aid (accessory ID) and iid (identifier ID) are shortcuts for the accessory, service, and characteristic UUIDs, see ~.homebridge/persist/IdentifierCache.xxxxxxxxxxxx.json (the xs are the MAC address from bridge.username in config.json). Apparently, Living Room 1 has aid 161. You see that HomeKit issues a single PUT call setting Brightness (iid 11) and On (iid 10). homebridge breaks up this request into two set events, which homebridge-hue receives separately. homebridge-hue combines the two events into a single PUT request to deCONZ. deCONZ sends two notifications back to homebridge-hue, that the light state has changed (still on deCONZ’s backlog to combine that into a single event). The first notification actually arrives before the PUT request has returned (the joy of asynchronous processing…).

1reaction
ebaauwcommented, Dec 16, 2017

You’ll probably need to collect all changes to a single light and combine that into a single request. See https://github.com/nfarina/homebridge/issues/1455.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blue-Enriched White Light Improves Performance but Not ...
Use of blue-enriched light has received increasing interest regarding its activating and performance sustaining effects.
Read more >
Light, sleep and circadian rhythms in older adults with ... - NCBI
(1994), Investigate effects of bright-light therapy on sleep time, behavior disorders and melatonin secretion on elderly people with dementia ...
Read more >
Preparation and photoelectrochemical behavior of 1,4,6,8,11 ...
Photoelectrochemical studies demonstrated that 1,4,6,8,11,13-hexazapentacene () exhibited active n-type semiconductor behavior under visible ...
Read more >
Environmental risks from artificial nighttime lighting ... - Science
Temporal change in light intensity. Relationships between light intensity values estimated from B and G bands of nighttime light emissions ...
Read more >
Dark Matters: The Effects of Artificial Lighting on Bats
For bats, this can also be advantageous because artificial light disrupts the evasive behaviour of most nocturnal Lepidoptera, rendering them ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found