Filter battery sensors from generated UI (#4799)

* Filter battery sensors from generated UI

* Use fancy TypeScript feature
This commit is contained in:
Paulus Schoutsen 2020-02-07 09:32:37 -08:00 committed by GitHub
parent 15e7b8117c
commit 8a4c52aeb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

1
src/data/sensor.ts Normal file
View File

@ -0,0 +1 @@
export const SENSOR_DEVICE_CLASS_BATTERY = "battery";

View File

@ -41,6 +41,7 @@ import {
EntityRegistryEntry, EntityRegistryEntry,
} from "../../../data/entity_registry"; } from "../../../data/entity_registry";
import { processEditorEntities } from "../editor/process-editor-entities"; import { processEditorEntities } from "../editor/process-editor-entities";
import { SENSOR_DEVICE_CLASS_BATTERY } from "../../../data/sensor";
const DEFAULT_VIEW_ENTITY_ID = "group.default_view"; const DEFAULT_VIEW_ENTITY_ID = "group.default_view";
const DOMAINS_BADGES = [ const DOMAINS_BADGES = [
@ -181,6 +182,11 @@ export const computeCards = (
conf.icon = stateObj.attributes.icon; conf.icon = stateObj.attributes.icon;
} }
entities.push(conf); entities.push(conf);
} else if (
domain === "sensor" &&
stateObj?.attributes.device_class === SENSOR_DEVICE_CLASS_BATTERY
) {
// Do nothing.
} else { } else {
let name: string; let name: string;
const entityConf = const entityConf =