1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00
Files
frontend/src/dialogs/more-info/const.ts
Paul Bottein 4986b013a2 Add new humidity control in humidifier more info (#17011)
* Add new humidity control in humidifier more info

* Fix humidifier card

* Some adjustments

* Add current label

* Some adjustments

* Clean code

* Remove unused code

* Fix merge

* Add current to main screen

* Remove toggle

* Add action

* Update buttons

* Add gallery

* Some fixes

* Add overflow

* Update src/dialogs/more-info/components/humidifier/ha-more-info-humidifier-humidity.ts

* Update src/dialogs/more-info/controls/more-info-humidifier.ts

Co-authored-by: Bram Kragten <mail@bramkragten.nl>

* Use climate translation

---------

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2023-08-08 11:07:46 +00:00

126 lines
3.0 KiB
TypeScript

import { HassEntity } from "home-assistant-js-websocket";
import { isComponentLoaded } from "../../common/config/is_component_loaded";
import { computeDomain } from "../../common/entity/compute_domain";
import { computeGroupDomain, GroupEntity } from "../../data/group";
import { CONTINUOUS_DOMAINS } from "../../data/logbook";
import { HomeAssistant } from "../../types";
export const DOMAINS_NO_INFO = ["camera", "configurator"];
/**
* Entity domains that should be editable *if* they have an id present;
* {@see shouldShowEditIcon}.
* */
export const EDITABLE_DOMAINS_WITH_ID = ["scene", "automation"];
/**
* Entity Domains that should always be editable; {@see shouldShowEditIcon}.
* */
export const EDITABLE_DOMAINS_WITH_UNIQUE_ID = ["script"];
/** Domains with with new more info design. */
export const DOMAINS_WITH_NEW_MORE_INFO = [
"alarm_control_panel",
"cover",
"climate",
"fan",
"humidifier",
"input_boolean",
"light",
"lock",
"siren",
"switch",
];
/** Domains with separate more info dialog. */
export const DOMAINS_WITH_MORE_INFO = [
"alarm_control_panel",
"automation",
"camera",
"climate",
"configurator",
"counter",
"cover",
"date",
"datetime",
"fan",
"group",
"humidifier",
"image",
"input_boolean",
"input_datetime",
"light",
"lock",
"media_player",
"person",
"remote",
"script",
"scene",
"siren",
"sun",
"switch",
"time",
"timer",
"update",
"vacuum",
"water_heater",
"weather",
];
/** Domains that do not show the default more info dialog content (e.g. the attribute section)
* and do not have a separate more info (so not in DOMAINS_WITH_MORE_INFO). */
export const DOMAINS_HIDE_DEFAULT_MORE_INFO = [
"input_number",
"input_select",
"input_text",
"number",
"scene",
"select",
"text",
"update",
"event",
];
/** Domains that should have the history hidden in the more info dialog. */
export const DOMAINS_MORE_INFO_NO_HISTORY = ["camera", "configurator"];
export const computeShowHistoryComponent = (
hass: HomeAssistant,
entityId: string
) =>
isComponentLoaded(hass, "history") &&
!DOMAINS_MORE_INFO_NO_HISTORY.includes(computeDomain(entityId));
export const computeShowLogBookComponent = (
hass: HomeAssistant,
entityId: string
): boolean => {
if (!isComponentLoaded(hass, "logbook")) {
return false;
}
const stateObj = hass.states[entityId];
if (!stateObj || stateObj.attributes.unit_of_measurement) {
return false;
}
const domain = computeDomain(entityId);
if (
CONTINUOUS_DOMAINS.includes(domain) ||
DOMAINS_MORE_INFO_NO_HISTORY.includes(domain)
) {
return false;
}
return true;
};
export const computeShowNewMoreInfo = (stateObj: HassEntity): boolean => {
const domain = computeDomain(stateObj.entity_id);
if (domain === "group") {
const groupDomain = computeGroupDomain(stateObj as GroupEntity);
return (
groupDomain != null &&
groupDomain !== "group" &&
DOMAINS_WITH_NEW_MORE_INFO.includes(groupDomain)
);
}
return DOMAINS_WITH_NEW_MORE_INFO.includes(domain);
};