mirror of
https://github.com/koush/scrypted.git
synced 2026-02-10 17:22:03 +00:00
server: secret menu to edit device id
This commit is contained in:
@@ -493,7 +493,7 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
await this.upsertDevice(plugin._id, device);
|
||||
this.upsertDevice(plugin._id, device);
|
||||
return this.runPlugin(plugin, pluginDebug);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Plugin } from '../db-types';
|
||||
import { getState } from "../state";
|
||||
import axios from 'axios';
|
||||
import semver from 'semver';
|
||||
import { sleep } from "../sleep";
|
||||
|
||||
export class PluginComponent {
|
||||
scrypted: ScryptedRuntime;
|
||||
@@ -11,6 +12,17 @@ export class PluginComponent {
|
||||
this.scrypted = scrypted;
|
||||
}
|
||||
|
||||
async renameDeviceId(id: string, newId: string) {
|
||||
const pluginDevice = this.scrypted.findPluginDeviceById(id);
|
||||
await this.kill(pluginDevice.pluginId);
|
||||
// wait for everything to settle.
|
||||
await sleep(2000);
|
||||
await this.scrypted.removeDevice(pluginDevice);
|
||||
pluginDevice._id = newId;
|
||||
await this.scrypted.datastore.upsert(pluginDevice);
|
||||
await this.scrypted.notifyPluginDeviceDescriptorChanged(pluginDevice);
|
||||
}
|
||||
|
||||
getNativeId(id: string) {
|
||||
return this.scrypted.findPluginDeviceById(id)?.nativeId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user