Skip to content

Commit

Permalink
Add 'Anywhere' prefix to home-wide sensors as room name suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
DouweM committed Feb 21, 2023
1 parent ab4b390 commit 8f8b567
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
36 changes: 18 additions & 18 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand Down Expand Up @@ -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
},
Expand All @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 2 additions & 3 deletions src/accessory_subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// "<Room> <Display Name>" so the "<Room>" 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 {
Expand Down

0 comments on commit 8f8b567

Please sign in to comment.