generated from homebridge/homebridge-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix plugin slows down warning Fixes #212
- Loading branch information
Showing
16 changed files
with
1,142 additions
and
1,222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
import { Service, Characteristic, CharacteristicEventTypes } from 'homebridge'; | ||
import { withDevice } from '../../with-device'; | ||
|
||
// https://developers.homebridge.io/#/characteristic/FilterLifeLevel | ||
export function add( | ||
maybeDevice: Promise<any>, | ||
service: Service, | ||
characteristic: typeof Characteristic.FilterLifeLevel, | ||
) { | ||
const useDevice = withDevice<number>(maybeDevice); | ||
|
||
maybeDevice.then((device) => { | ||
device.on('filterLifeChanged', (value: number) => { | ||
service.updateCharacteristic(characteristic, value); | ||
}); | ||
}); | ||
|
||
return service.getCharacteristic(characteristic).on( | ||
CharacteristicEventTypes.GET, | ||
useDevice(async (device) => device.property('filter_life').value), | ||
); | ||
return service.getCharacteristic(characteristic).onGet(async () => { | ||
const device = await maybeDevice; | ||
return device.property('filter_life').value; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.