From c6c605715f7115af16525b2cf410e94612f2dd9e Mon Sep 17 00:00:00 2001 From: dgreif Date: Thu, 16 Jan 2020 21:11:13 -0700 Subject: [PATCH] chore(homebridge): remove v3 conversion step to update homebridge plugin name BREAKING CHANGE: Conversion step to change from `homebridge-ring-alarm` to `homebridge-ring` has been removed. If you are updating from v2, please first upgrade to version `5.13.1` before upgrading to version 6+ --- homebridge/index.ts | 44 +------------------------------------ homebridge/plugin-info.ts | 4 ---- homebridge/ring-platform.ts | 3 ++- 3 files changed, 3 insertions(+), 48 deletions(-) delete mode 100644 homebridge/plugin-info.ts diff --git a/homebridge/index.ts b/homebridge/index.ts index 9722394a..2e4f6ad7 100644 --- a/homebridge/index.ts +++ b/homebridge/index.ts @@ -1,15 +1,5 @@ -import { RingPlatform } from './ring-platform' +import { platformName, pluginName, RingPlatform } from './ring-platform' import { hap } from './hap' -import { readFileSync, writeFileSync } from 'fs' -import { join as joinPath } from 'path' -import { - oldPlatformName, - oldPluginName, - platformName, - pluginName -} from './plugin-info' -import { logError } from '../api/util' -import { updateHomebridgeConfig } from './config' export default function(homebridge: any) { hap.PlatformAccessory = homebridge.platformAccessory @@ -19,37 +9,5 @@ export default function(homebridge: any) { hap.AccessoryCategories = homebridge.hap.Accessory.Categories hap.StreamController = homebridge.hap.StreamController - try { - // This plugin was changed from homebridge-ring-alarm to homebridge-ring - // This code cleans up the config/cache files to point to the new plugin - - const cachedAccessoriesPath = joinPath( - homebridge.user.cachedAccessoryPath(), - 'cachedAccessories' - ), - cachedAccessories = readFileSync(cachedAccessoriesPath).toString(), - updatedAccessories = cachedAccessories - .replace(new RegExp(oldPluginName, 'g'), pluginName) - .replace(new RegExp(oldPlatformName, 'g'), platformName) - - let filesChanged = updateHomebridgeConfig(homebridge, config => { - return config.replace(`"${oldPlatformName}"`, `"${platformName}"`) - }) - - if (cachedAccessories !== updatedAccessories) { - writeFileSync(cachedAccessoriesPath, updatedAccessories) - filesChanged = true - } - - if (filesChanged) { - logError( - 'Your Ring Alarm config has been updated to new Ring config. This is a one time thing, and you do not need to do anything. Just restart homebridge and everything should start normally.' - ) - process.exit(1) - } - } catch (_) { - void _ - } - homebridge.registerPlatform(pluginName, platformName, RingPlatform, true) } diff --git a/homebridge/plugin-info.ts b/homebridge/plugin-info.ts deleted file mode 100644 index d7247b5b..00000000 --- a/homebridge/plugin-info.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const platformName = 'Ring' -export const pluginName = 'homebridge-ring' -export const oldPlatformName = 'RingAlarm' -export const oldPluginName = 'homebridge-ring-alarm' diff --git a/homebridge/ring-platform.ts b/homebridge/ring-platform.ts index 7718cdb7..fe4dd77b 100644 --- a/homebridge/ring-platform.ts +++ b/homebridge/ring-platform.ts @@ -24,7 +24,6 @@ import { Switch } from './switch' import { Camera } from './camera' import { PanicButtons } from './panic-buttons' import { RingAuth } from '../api/rest-client' -import { platformName, pluginName } from './plugin-info' import { useLogger } from '../api/util' import { BaseAccessory } from './base-accessory' import { FloodFreezeSensor } from './flood-freeze-sensor' @@ -36,6 +35,8 @@ const debug = __filename.includes('release-homebridge'), RingDeviceType.Keypad ] +export const platformName = 'Ring' +export const pluginName = 'homebridge-ring' process.env.RING_DEBUG = debug ? 'true' : '' function getAccessoryClass(