Skip to content

Commit

Permalink
State reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthernMan54 committed Oct 27, 2024
1 parent 489d0fd commit c30427d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/hap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,13 @@ export class Hap {
*/
async handleHapEvent(events) {
for (const event of events) {
const accessories = this.services.filter(s =>
s.instance.ipAddress === event.host && s.instance.port === event.port && s.aid === event.aid);
const service = accessories.find(x => x.serviceCharacteristics.find(c => c.iid === event.iid));
if (service) {
const characteristic = service.serviceCharacteristics.find(c => c.iid === event.iid);
characteristic.value = event.value;
this.reportStateSubject.next(service.uniqueId);
const index = this.services.findIndex(item => item.uniqueId === event.uniqueId);
if (index === -1) {
this.log.debug(`[handleHapEvent] Service not found in services list ${event}`);
return
} else {
this.services[index] = event;
this.reportStateSubject.next(event.uniqueId);
}
}
}
Expand Down

0 comments on commit c30427d

Please sign in to comment.