From 8f8b567ed0d7247889b99dedd9055e3d1fd625fd Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 20 Feb 2023 21:45:05 -0600 Subject: [PATCH] Add 'Anywhere' prefix to home-wide sensors as room name suggestion --- README.md | 2 +- config.schema.json | 36 ++++++++++++++++++------------------ package.json | 2 +- src/accessory_subject.ts | 5 ++--- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 78d0dc9..cf8b714 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ For example, `Douwe's iPhone` (English), `iPhone de Douwe` (Spanish), and `iPhon Other device types to create sensors for can be enabled in Settings. Device types are determined using the device fingerprint in the UniFi Network UI, either detected automatically or assigned manually. -In addition to sensors for whether a specific device in a specific room, sensors can be created for whether a specific device is in any room, whether any device of a specific type is in a specific room, or whether any device of a specific type is in any room. +In addition to sensors for whether a specific device in a specific room, sensors can be created for whether a specific device is in any room (with the special name `Anywhere`), whether any device of a specific type is in a specific room, or whether any device of a specific type is in any room. PS. To see these smartphones in your macOS menu bar as well, check out [XBar + UniFi = Who's Home?](https://github.com/DouweM/xbar-whos-home-unifi). diff --git a/config.schema.json b/config.schema.json index a2c7462..2c787c8 100644 --- a/config.schema.json +++ b/config.schema.json @@ -63,7 +63,7 @@ }, "deviceType": { "title": "Devices", - "description": "Below, you can specify which sensors to create for each device type. Create room-specific sensors to know where people or devices are. Create any-device sensors to use in automations, e.g. \"Turn off the lights when '[Room] Anyone' becomes inactive\".", + "description": "Below, you can specify which sensors to create for each device type. Note that the room name prefix is automatically hidden by the Home app once the sensor is assigned to the corresponding room. Create room-specific sensors to know where people or devices are. Create any-device sensors to use in automations, e.g. \"Turn off the lights in [Room] when '[Room] Anyone' becomes inactive\".", "type": "object", "properties": { "smartphone": { @@ -76,7 +76,7 @@ "default": true }, "homeAccessory": { - "title": "`[Device]`: A specific smartphone in any room (shows as `[Owner]` if configured above)", + "title": "`Anywhere [Device]`: A specific smartphone in any room (shows as `[Owner]` if configured above)", "type": "boolean", "default": false }, @@ -86,7 +86,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any smartphone`: Any smartphone in any room (shows as `Anyone` if configured above)", + "title": "`Anywhere Any smartphone`: Any smartphone in any room (shows as `Anywhere Anyone` if configured above)", "type": "boolean", "default": false }, @@ -107,7 +107,7 @@ "default": true }, "homeAccessory": { - "title": "`[Device]`: A specific smart watch in any room (shows as `[Owner]` if configured above)", + "title": "`Anywhere [Device]`: A specific smart watch in any room (shows as `[Owner]` if configured above)", "type": "boolean", "default": false }, @@ -117,7 +117,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any smart watch`: Any smart watch in any room (shows as `Anyone` if configured above)", + "title": "`Anywhere Any smart watch`: Any smart watch in any room (shows as `Anywhere Anyone` if configured above)", "type": "boolean", "default": false }, @@ -139,7 +139,7 @@ "default": false }, "homeAccessory": { - "title": "`[Device]`: A specific laptop in any room", + "title": "`Anywhere [Device]`: A specific laptop in any room", "type": "boolean", "default": false }, @@ -149,7 +149,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any laptop`: Any laptop in any room", + "title": "`Anywhere Any laptop`: Any laptop in any room", "type": "boolean", "default": false }, @@ -170,7 +170,7 @@ "default": false }, "homeAccessory": { - "title": "`[Device]`: A specific tablet in any room", + "title": "`Anywhere [Device]`: A specific tablet in any room", "type": "boolean", "default": false }, @@ -180,7 +180,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any tablet`: Any tablet in any room", + "title": "`Anywhere Any tablet`: Any tablet in any room", "type": "boolean", "default": false }, @@ -201,7 +201,7 @@ "default": false }, "homeAccessory": { - "title": "`[Device]`: A specific e-reader in any room", + "title": "`Anywhere [Device]`: A specific e-reader in any room", "type": "boolean", "default": false }, @@ -211,7 +211,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any e-reader`: Any e-reader in any room", + "title": "`Anywhere Any e-reader`: Any e-reader in any room", "type": "boolean", "default": false }, @@ -233,7 +233,7 @@ "default": false }, "homeAccessory": { - "title": "`[Device]`: A specific game console in any room", + "title": "`Anywhere [Device]`: A specific game console in any room", "type": "boolean", "default": false }, @@ -243,7 +243,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any game console`: Any game console in any room", + "title": "`Anywhere Any game console`: Any game console in any room", "type": "boolean", "default": false }, @@ -264,7 +264,7 @@ "default": false }, "homeAccessory": { - "title": "`[Device]`: A specific handheld in any room", + "title": "`Anywhere [Device]`: A specific handheld in any room", "type": "boolean", "default": false }, @@ -274,7 +274,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any handheld`: Any handheld in any room", + "title": "`Anywhere Any handheld`: Any handheld in any room", "type": "boolean", "default": false }, @@ -295,7 +295,7 @@ "default": false }, "homeAccessory": { - "title": "`[Client]`: A specific client in any room", + "title": "`Anywhere [Client]`: A specific client in any room", "type": "boolean", "default": false }, @@ -351,7 +351,7 @@ "default": true }, "homeAccessory": { - "title": "`[Device]`: A specific device in any room", + "title": "`Anywhere [Device]`: A specific device in any room", "type": "boolean", "default": false }, @@ -361,7 +361,7 @@ "default": false }, "homeCatchallAccessory": { - "title": "`Any [Rule Label]`: Any device in any room", + "title": "`Anywhere Any [Rule Label]`: Any device in any room", "type": "boolean", "default": false }, diff --git a/package.json b/package.json index 6af3b8f..ce2ccb3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge UniFi Occupancy", "name": "homebridge-unifi-occupancy", - "version": "1.2.0", + "version": "1.2.1", "description": "Homebridge plugin that adds HomeKit occupancy sensors for for selected (types of) devices on a UniFi network to your iOS Home app.", "license": "Apache-2.0", "repository": { diff --git a/src/accessory_subject.ts b/src/accessory_subject.ts index 428dc4c..29d95cb 100644 --- a/src/accessory_subject.ts +++ b/src/accessory_subject.ts @@ -27,12 +27,11 @@ export class AccessorySubject { } accessoryDisplayName(room: string | null) : string { - if (!room || this.displayName.startsWith(room)) { + if (room && this.displayName.startsWith(room)) { return this.displayName; } - // " " so the "" prefix is hidden by the Home app if it matches the room name - return `${room} ${this.displayName}`; + return `${room || 'Anywhere'} ${this.displayName}`; } isAccessoryActive(room: string | null) : boolean {