1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Show logbook component in more info for non-numeric values (#22997)

* if isNumeric ignore CONTINUOUS_DOMAINS

* use isNumeric  logic from history.ts

* removed check for stateObj.attributes.unit_of_measurement

* pass numericDevicesClasses to computeShowLogBookComponent

---------

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
libe.net
2025-01-08 09:17:39 +01:00
committed by GitHub
parent 85bebfc309
commit c50f701160
5 changed files with 85 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import type { GroupEntity } from "../../data/group";
import { computeGroupDomain } from "../../data/group";
import { CONTINUOUS_DOMAINS } from "../../data/logbook";
import type { HomeAssistant } from "../../types";
import { isNumericEntity } from "../../data/history";
export const DOMAINS_NO_INFO = ["camera", "configurator"];
/**
@@ -98,20 +99,27 @@ export const computeShowHistoryComponent = (
export const computeShowLogBookComponent = (
hass: HomeAssistant,
entityId: string
entityId: string,
sensorNumericalDeviceClasses: string[] = []
): boolean => {
if (!isComponentLoaded(hass, "logbook")) {
return false;
}
const stateObj = hass.states[entityId];
if (!stateObj || stateObj.attributes.unit_of_measurement) {
if (!stateObj) {
return false;
}
const domain = computeDomain(entityId);
if (
CONTINUOUS_DOMAINS.includes(domain) ||
(CONTINUOUS_DOMAINS.includes(domain) &&
isNumericEntity(
domain,
stateObj,
undefined,
sensorNumericalDeviceClasses
)) ||
DOMAINS_MORE_INFO_NO_HISTORY.includes(domain)
) {
return false;