Skip to content

Commit

Permalink
chore(homebridge): remove v3 conversion step to update homebridge plu…
Browse files Browse the repository at this point in the history
…gin 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+
  • Loading branch information
dgreif committed Jan 17, 2020
1 parent e415605 commit c6c6057
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 48 deletions.
44 changes: 1 addition & 43 deletions homebridge/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}
4 changes: 0 additions & 4 deletions homebridge/plugin-info.ts

This file was deleted.

3 changes: 2 additions & 1 deletion homebridge/ring-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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(
Expand Down

0 comments on commit c6c6057

Please sign in to comment.