Allow globs and regex for device names. Fix #20
This commit is contained in:
parent
05a3d0a9c5
commit
65490abff1
13
README.md
13
README.md
@ -226,7 +226,6 @@ filter:
|
|||||||
Show everything that has "light" in its name, but isn't a light, and all switches in the living room:
|
Show everything that has "light" in its name, but isn't a light, and all switches in the living room:
|
||||||
```yaml
|
```yaml
|
||||||
type: custom:auto-entities
|
type: custom:auto-entities
|
||||||
show_empty: false
|
|
||||||
card:
|
card:
|
||||||
type: entities
|
type: entities
|
||||||
title: Lights on
|
title: Lights on
|
||||||
@ -241,5 +240,17 @@ filter:
|
|||||||
area: Living Room
|
area: Living Room
|
||||||
```
|
```
|
||||||
|
|
||||||
|
List every sensor belonging to any iPhone:
|
||||||
|
```yaml
|
||||||
|
type: custom:auto-entities
|
||||||
|
card:
|
||||||
|
type: entities
|
||||||
|
title: Phones
|
||||||
|
show_header_toggle: false
|
||||||
|
filter:
|
||||||
|
include:
|
||||||
|
- device: /iPhone/
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
<a href="https://www.buymeacoffee.com/uqD6KHCdJ" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/white_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
|
<a href="https://www.buymeacoffee.com/uqD6KHCdJ" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/white_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -92,16 +92,25 @@ export function entity_filter(hass, filter) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "device":
|
case "device":
|
||||||
const _deviceEntities = deviceEntities(deviceByName(value));
|
let _deviceMatch = false;
|
||||||
if(!_deviceEntities.includes(entity.entity_id))
|
for(const d of window.cardToolsData.devices) {
|
||||||
return false;
|
if (match(value, d.name)){
|
||||||
|
if(deviceEntities(d).includes(entity.entity_id))
|
||||||
|
_deviceMatch = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!_deviceMatch) return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "area":
|
case "area":
|
||||||
const _areaDevices = areaDevices(areaByName(value));
|
let _areaMatch = false;
|
||||||
const _areaEntities = _areaDevices.flatMap(deviceEntities);
|
for (const a of window.cardToolsData.areas) {
|
||||||
if(!_areaEntities.includes(entity.entity_id))
|
if(match(value, a.name)) {
|
||||||
return false;
|
if(areaDevices(a).flatMap(deviceEntities).includes(entity.entity_id))
|
||||||
|
_areaMatch = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!_areaMatch) return false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user