File tree Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { stripPrefixFromEntityName } from "./strip_prefix_from_entity_name";
5
5
import { computeStateName } from "./compute_state_name" ;
6
6
import { computeDeviceName } from "./compute_device_name" ;
7
7
import { computeAreaName } from "./compute_area_name" ;
8
+ import { computeFloorName } from "./compute_floor_name" ;
8
9
9
10
export const computeEntityFullName = (
10
11
stateObj : HassEntity ,
@@ -85,3 +86,22 @@ export const computeEntityAreaName = (
85
86
86
87
return area ? computeAreaName ( area ) : undefined ;
87
88
} ;
89
+
90
+ export const computeEntityFloorName = (
91
+ stateObj : HassEntity ,
92
+ entities : HomeAssistant [ "entities" ] ,
93
+ devices : HomeAssistant [ "devices" ] ,
94
+ areas : HomeAssistant [ "areas" ] ,
95
+ floors : HomeAssistant [ "floors" ]
96
+ ) : string | undefined => {
97
+ const entry = entities [ stateObj . entity_id ] as
98
+ | EntityRegistryDisplayEntry
99
+ | undefined ;
100
+ const device = entry ?. device_id ? devices [ entry ?. device_id ] : undefined ;
101
+
102
+ const areaId = entry ?. area_id || device ?. area_id ;
103
+ const area = areaId ? areas [ areaId ] : undefined ;
104
+ const floor = area ?. floor_id ? floors [ area ?. floor_id ] : undefined ;
105
+
106
+ return floor ? computeFloorName ( floor ) : undefined ;
107
+ } ;
Original file line number Diff line number Diff line change
1
+ import { FloorRegistryEntry } from "../../data/floor_registry" ;
2
+
3
+ export const computeFloorName = (
4
+ floor : FloorRegistryEntry
5
+ ) : string | undefined => floor . name ?. trim ( ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { computeDomain } from "../../common/entity/compute_domain";
9
9
import {
10
10
computeEntityAreaName ,
11
11
computeEntityDeviceName ,
12
+ computeEntityFloorName ,
12
13
computeEntityFullName ,
13
14
computeEntityName ,
14
15
} from "../../common/entity/compute_entity_name" ;
@@ -343,6 +344,13 @@ export class HaEntityPicker extends LitElement {
343
344
hass . devices ,
344
345
hass . areas
345
346
) ;
347
+ const floorName = computeEntityFloorName (
348
+ stateObj ,
349
+ hass . entities ,
350
+ hass . devices ,
351
+ hass . areas ,
352
+ hass . floors
353
+ ) ;
346
354
const deviceName = computeEntityDeviceName (
347
355
stateObj ,
348
356
hass . entities ,
@@ -361,6 +369,7 @@ export class HaEntityPicker extends LitElement {
361
369
const entityContext = [
362
370
entityName !== deviceName ? deviceName : undefined ,
363
371
areaName ,
372
+ floorName ,
364
373
]
365
374
. filter ( Boolean )
366
375
. join ( " ⸱ " ) ;
@@ -373,6 +382,7 @@ export class HaEntityPicker extends LitElement {
373
382
displayedName ?? "" ,
374
383
areaName ?? "" ,
375
384
deviceName ?? "" ,
385
+ floorName ?? "" ,
376
386
] . filter ( Boolean ) ,
377
387
entity_name : entityName ,
378
388
entity_context : entityContext ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { computeDomain } from "../../common/entity/compute_domain";
22
22
import {
23
23
computeEntityAreaName ,
24
24
computeEntityDeviceName ,
25
+ computeEntityFloorName ,
25
26
computeEntityName ,
26
27
} from "../../common/entity/compute_entity_name" ;
27
28
import { shouldHandleRequestSelectedEvent } from "../../common/mwc/handle-request-selected-event" ;
@@ -301,6 +302,16 @@ export class MoreInfoDialog extends LitElement {
301
302
)
302
303
: "" ;
303
304
305
+ const floorName = stateObj
306
+ ? computeEntityFloorName (
307
+ stateObj ,
308
+ this . hass . entities ,
309
+ this . hass . devices ,
310
+ this . hass . areas ,
311
+ this . hass . floors
312
+ )
313
+ : "" ;
314
+
304
315
const deviceName = stateObj
305
316
? computeEntityDeviceName ( stateObj , this . hass . entities , this . hass . devices )
306
317
: "" ;
@@ -309,7 +320,11 @@ export class MoreInfoDialog extends LitElement {
309
320
310
321
const subtitle = this . _childView ?. viewTitle
311
322
? undefined
312
- : [ entityName !== deviceName ? deviceName : undefined , areaName ] // Do not include device name if it's the same as entity name
323
+ : [
324
+ entityName !== deviceName ? deviceName : undefined ,
325
+ areaName ,
326
+ floorName ,
327
+ ] // Do not include device name if it's the same as entity name
313
328
. filter ( Boolean )
314
329
. join ( " ⸱ " ) ;
315
330
You can’t perform that action at this time.
0 commit comments