ability to specify sonos service name and id

This commit is contained in:
simojenki
2021-01-31 10:08:31 +11:00
parent ad09a88de8
commit 1e8820b419
7 changed files with 59 additions and 38 deletions

View File

@@ -18,10 +18,10 @@ export type Service = {
export type BonobRegistrationStatus = 'registered' | 'not-registered'
export const BONOB_SERVICE: Service = {
name: "bonob",
id: 245
}
export const bonobService = (name: string, id: number): Service => ({
name,
id
})
export interface Sonos {
devices: () => Promise<Device[]>;
@@ -41,8 +41,8 @@ export const servicesFrom = (devices: Device[]) =>
"name"
);
export const registrationStatus = (services: Service[]): BonobRegistrationStatus => {
if(services.find(s => s.id == BONOB_SERVICE.id) != undefined) {
export const registrationStatus = (services: Service[], bonob: Service): BonobRegistrationStatus => {
if(services.find(s => s.id == bonob.id) != undefined) {
return "registered"
} else {
return "not-registered"