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

Error : Unhandled rejection TypeError: Cannot read properties of undefined (reading 'updateCharacteristic') #16

Open
nodecentral opened this issue Mar 14, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@nodecentral
Copy link

Nothing visible that i can see, however I am still setting things up..

Unsure how to explain what it is, but have included the logs below..

It happens after a while, so it seems to be periodic,

Expected behavior:

No errors :-) ?

Logs:


[3/14/2023, 9:29:51 AM] [homebridge-unifi-occupancy] Updated accessory status: "Kitchen Guest: 26:42:xx:9b:ec:ii" active
[3/14/2023, 9:29:51 AM] [homebridge-unifi-occupancy] Updated accessory status: "Kitchen Joe" active
[3/14/2023, 10:22:37 AM] [homebridge-unifi-occupancy] Updated accessory status: "Kitchen Guest: 26:42:xx:9b:ec:ii" inactive
Unhandled rejection TypeError: Cannot read properties of undefined (reading 'updateCharacteristic')
    at ClientAccessoryHandler.update (/homebridge/node_modules/homebridge-unifi-occupancy/src/accessory_handler.ts:147:21)
    at UnifiOccupancyPlatform.updateAccessory (/homebridge/node_modules/homebridge-unifi-occupancy/src/platform.ts:323:29)
    at /homebridge/node_modules/homebridge-unifi-occupancy/src/platform.ts:301:16
    at Map.forEach (<anonymous>)
    at UnifiOccupancyPlatform.updateAccessories (/homebridge/node_modules/homebridge-unifi-occupancy/src/platform.ts:300:22)
    at /homebridge/node_modules/homebridge-unifi-occupancy/src/platform.ts:268:24
    at tryCatcher (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/homebridge/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:471:21)

Plugin Config:

Screenshots:

Environment:

  • Plugin Version:
  • Homebridge Version: 1.6.1
  • Node.js Version: 18.4
  • NPM Version:
  • Operating System: Docker
@nodecentral nodecentral added the bug Something isn't working label Mar 14, 2023
@DouweM
Copy link
Owner

DouweM commented Mar 15, 2023

Thanks for the report, I think this bug was introduced in my recent refactor. That's what I get for not having any tests 😅 I'll look into it later this week or this weekend!

@DouweM
Copy link
Owner

DouweM commented Mar 18, 2023

@nodecentral Can you turn on Debug logging in Homebridge (UI X) settings, and share the full logs the next time this happens again? I'd like to understand more clearly exactly what the properties are of the accessory that's being updated when this error occurs.

@Z1mDMan
Copy link

Z1mDMan commented May 31, 2023

I'm seeing a similar issue. I will open a new issue report since the output is different. I have just enabled debug logging on my homebridge.

@joecan00
Copy link

Was there ever a fix for this?

@EnixCoda
Copy link

EnixCoda commented Oct 30, 2023

The error seems caused due to lack of type definition in this function

function ensure(map, uuid, updater, builder) {
let item = map.get(uuid) || null;
if (item) {
updater(item);
} else {
item = builder();
if (item) {
map.set(uuid, item);
}
}
return item;
}

Then in the constructor of a child class of AccessoryHandler arose.

I tried to add type definition

https://github.com/EnixCoda/homebridge-unifi-occupancy/blob/abe891065bf5c4bd247e0530e1caacbd4b9b0fa3/src/platform.ts#L18-L29

function ensure<K, V>(map: Map<K, V>, uuid: K, updater: (item: NonNullable<V>) => void, builder: () => V) {
  let item: V | null = map.get(uuid) || null;
  if (item) {
    updater(item);
  } else {
    item = builder();
    if (item) {
      map.set(uuid, item);
    }
  }
  return item;
}

but a type error arose from ensureAccessoryHandler method

image

I got stuck here because I'm not familiar with this repo. IMHO, I'd suggest the maintainer start from fixing the type errors

@jondthompson
Copy link

I'm still getting this error, or one like it..

Unhandled rejection TypeError: Cannot read properties of undefined (reading 'updateCharacteristic')
at ClientAccessoryHandler.update (/usr/lib/node_modules/homebridge-unifi-occupancy/src/accessory_handler.ts:147:21)
at UnifiOccupancyPlatform.updateAccessoryHandler (/usr/lib/node_modules/homebridge-unifi-occupancy/src/platform.ts:374:29)
at /usr/lib/node_modules/homebridge-unifi-occupancy/src/platform.ts:362:12
at Map.forEach ()
at UnifiOccupancyPlatform.updateAccessories (/usr/lib/node_modules/homebridge-unifi-occupancy/src/platform.ts:360:22)
at UnifiOccupancyPlatform.refreshAccessories (/usr/lib/node_modules/homebridge-unifi-occupancy/src/platform.ts:321:10)
at /usr/lib/node_modules/homebridge-unifi-occupancy/src/platform.ts:284:24
at tryCatcher (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/homebridge-unifi-occupancy/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (node:internal/timers:478:21)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants