Skip to content

Commit

Permalink
remove experimental from COSmokeSensor, update garage door initializa…
Browse files Browse the repository at this point in the history
…tion message
  • Loading branch information
dkerr64 committed Dec 9, 2023
1 parent 6dbf2bf commit 4af1353
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge YoLink",
"name": "homebridge-yolink",
"version": "1.4.4-beta.3",
"version": "1.4.4-beta.5",
"description": "Connect to YoLink.",
"license": "Apache-2.0",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/deviceHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const deviceFeatures = {
PowerFailureAlarm: { hasBattery: true },
Dimmer: { hasBattery: false },
InfraredRemoter: { hasBattery: true },
COSmokeSensor: { hasBattery: true, experimental: true },
COSmokeSensor: { hasBattery: true },
};

export const initDeviceService = {
Expand Down
2 changes: 1 addition & 1 deletion src/garageDoor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function initGarageDoor(this: YoLinkPlatformAccessory): Promise<voi

// Call get handler to initialize data fields to current state and set
// timer to regularly update the data.
await this.refreshDataTimer(handleGetBlocking.bind(this, doorSensor));
await this.refreshDataTimer(handleGetBlocking.bind(this, doorSensor), 'sensor');
// above must await because we use doorSensor in handleGet for doorController
await this.refreshDataTimer(handleGetBlocking.bind(this, doorController));

Expand Down
2 changes: 2 additions & 0 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export class YoLinkHomebridgePlatform implements DynamicPlatformPlugin {
const device: YoLinkDevice = accessory.context.device;
const device2: YoLinkDevice = accessory.context.device2;
if (device2) {
device2.name = device2.config.name ?? device2.name;
device2.deviceMsgName = `${device2.modelName} (${device2.deviceId}) ${device2.name}`;
// Delete any existing garage door accessories that do not exactly match one
// that we have setup in the config file.
if (!this.config.garageDoors?.some(x => x.controller === device.deviceId && x.sensor === device2.deviceId)) {
Expand Down
8 changes: 4 additions & 4 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ export class YoLinkPlatformAccessory {
* right time to force call to yolinkAPI.getDeviceState. All this to optimize
* performance of user experience.
*/
async refreshDataTimer(this: YoLinkPlatformAccessory, handleGet: () => Promise<CharacteristicValue>) {
async refreshDataTimer(this: YoLinkPlatformAccessory, handleGet: () => Promise<CharacteristicValue>, dev = 'main') {
const platform: YoLinkHomebridgePlatform = this.platform;
const device: YoLinkDevice = this.accessory.context.device;
const device: YoLinkDevice = (dev === 'main') ? this.accessory.context.device : this.accessory.context.device2;

await handleGet();
platform.log.info(`Device initialized: ${device.deviceMsgName}`);
Expand Down Expand Up @@ -219,11 +219,11 @@ export class YoLinkPlatformAccessory {
batteryLevel = ((device.data?.battery ?? device.data?.state?.battery) ?? 0) * 25;
const msg = `[${device.deviceMsgName}] Battery level: ${batteryLevel}%`;
if (batteryLevel <= 25) {
device.batteryService.updateCharacteristic(platform.Characteristic.StatusLowBattery,
device.batteryService?.updateCharacteristic(platform.Characteristic.StatusLowBattery,
platform.api.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW);
this.platform.log.warn(msg);
} else {
device.batteryService.updateCharacteristic(platform.Characteristic.StatusLowBattery,
device.batteryService?.updateCharacteristic(platform.Characteristic.StatusLowBattery,
platform.api.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL);
this.platform.verboseLog(msg);
}
Expand Down

0 comments on commit 4af1353

Please sign in to comment.