mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
computeStateDomain instead of computeDmoain
This commit is contained in:
parent
7b3b717f43
commit
3fa9896543
@ -5,7 +5,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||
import './ha-automation-editor.js';
|
||||
import './ha-automation-picker.js';
|
||||
|
||||
import computeDomain from '../../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain.js';
|
||||
|
||||
class HaConfigAutomation extends PolymerElement {
|
||||
static get template() {
|
||||
@ -76,7 +76,7 @@ class HaConfigAutomation extends PolymerElement {
|
||||
Object.keys(hass.states).forEach(function (key) {
|
||||
var entity = hass.states[key];
|
||||
|
||||
if (computeDomain(entity) === 'automation' &&
|
||||
if (computeStateDomain(entity) === 'automation' &&
|
||||
'id' in entity.attributes) {
|
||||
automations.push(entity);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import '../ha-entity-config.js';
|
||||
import './ha-form-customize.js';
|
||||
|
||||
import computeStateName from '../../../js/common/entity/compute_state_name.js';
|
||||
import computeDomain from '../../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain.js';
|
||||
import sortByName from '../../../js/common/entity/states_sort_by_name.js';
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@ class HaConfigCustomize extends window.hassMixins.LocalizeMixin(PolymerElement)
|
||||
value: {
|
||||
component: 'ha-form-customize',
|
||||
computeSelectCaption: stateObj =>
|
||||
computeStateName(stateObj) + ' (' + computeDomain(stateObj) + ')'
|
||||
computeStateName(stateObj) + ' (' + computeStateDomain(stateObj) + ')'
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ import './ha-script-editor.js';
|
||||
import './ha-script-picker.js';
|
||||
|
||||
import computeStateName from '../../../js/common/entity/compute_state_name.js';
|
||||
import computeDomain from '../../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain.js';
|
||||
|
||||
class HaConfigScript extends PolymerElement {
|
||||
static get template() {
|
||||
@ -77,7 +77,7 @@ class HaConfigScript extends PolymerElement {
|
||||
Object.keys(hass.states).forEach(function (key) {
|
||||
var entity = hass.states[key];
|
||||
|
||||
if (computeDomain(entity) === 'script') {
|
||||
if (computeStateDomain(entity) === 'script') {
|
||||
scripts.push(entity);
|
||||
}
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ import './zwave-values.js';
|
||||
|
||||
import sortByName from '../../../js/common/entity/states_sort_by_name.js';
|
||||
import computeStateName from '../../../js/common/entity/compute_state_name.js';
|
||||
import computeDomain from '../../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain.js';
|
||||
/*
|
||||
* @appliesMixin window.hassMixins.LocalizeMixin
|
||||
*/
|
||||
@ -397,7 +397,7 @@ class HaConfigZwave extends window.hassMixins.LocalizeMixin(PolymerElement) {
|
||||
}
|
||||
|
||||
computeSelectCaptionEnt(stateObj) {
|
||||
return (computeDomain(stateObj) + '.'
|
||||
return (computeStateDomain(stateObj) + '.'
|
||||
+ computeStateName(stateObj));
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import '../../src/components/ha-menu-button.js';
|
||||
import '../../src/util/hass-mixins.js';
|
||||
import './ha-entity-marker.js';
|
||||
|
||||
import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../js/common/entity/compute_state_domain.js';
|
||||
import computeStateName from '../../js/common/entity/compute_state_name.js';
|
||||
|
||||
Leaflet.Icon.Default.imagePath = '/static/images/leaflet';
|
||||
@ -109,7 +109,7 @@ class HaPanelMap extends window.hassMixins.LocalizeMixin(PolymerElement) {
|
||||
var title = computeStateName(entity);
|
||||
|
||||
if ((entity.attributes.hidden &&
|
||||
computeDomain(entity) !== 'zone') ||
|
||||
computeStateDomain(entity) !== 'zone') ||
|
||||
entity.state === 'home' ||
|
||||
!('latitude' in entity.attributes) ||
|
||||
!('longitude' in entity.attributes)) {
|
||||
@ -118,7 +118,7 @@ class HaPanelMap extends window.hassMixins.LocalizeMixin(PolymerElement) {
|
||||
|
||||
var icon;
|
||||
|
||||
if (computeDomain(entity) === 'zone') {
|
||||
if (computeStateDomain(entity) === 'zone') {
|
||||
// DRAW ZONE
|
||||
if (entity.attributes.passive) return;
|
||||
|
||||
|
@ -53,7 +53,7 @@ import computeStateName from '../../js/common/entity/compute_state_name.js';
|
||||
|
||||
<img src="[[cameraFeedSrc]]" class="camera-feed" hidden\$="[[!imageLoaded]]" alt="[[_computeStateName(stateObj)]]">
|
||||
<div class="caption">
|
||||
[[computeStateName(stateObj)]]
|
||||
[[_computeStateName(stateObj)]]
|
||||
<template is="dom-if" if="[[!imageLoaded]]">
|
||||
([[localize('ui.card.camera.not_available')]])
|
||||
</template>
|
||||
|
@ -7,7 +7,7 @@ import '../components/ha-card.js';
|
||||
import '../state-summary/state-card-content.js';
|
||||
import '../util/hass-mixins.js';
|
||||
|
||||
import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../js/common/entity/compute_state_domain.js';
|
||||
import computeStateName from '../../js/common/entity/compute_state_name.js';
|
||||
import stateMoreInfoType from '../../js/common/entity/state_more_info_type.js';
|
||||
import canToggleState from '../../js/common/entity/can_toggle_state.js';
|
||||
@ -86,7 +86,7 @@ class HaEntitiesCard extends
|
||||
if (groupEntity) {
|
||||
return computeStateName(groupEntity).trim();
|
||||
}
|
||||
const domain = computeDomain(states[0]);
|
||||
const domain = computeStateDomain(states[0]);
|
||||
return (localize && localize(`domain.${domain}`)) || domain.replace(/_/g, ' ');
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||
|
||||
import { STATES_OFF } from '../../../js/common/const.js';
|
||||
import computeDomain from '../../../js/common/entity/compute_domain';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain';
|
||||
|
||||
class HaEntityToggle extends PolymerElement {
|
||||
static get template() {
|
||||
@ -116,7 +116,7 @@ class HaEntityToggle extends PolymerElement {
|
||||
// result in the entity to be turned on. Since the state is not changing,
|
||||
// the resync is not called automatic.
|
||||
callService(turnOn) {
|
||||
const stateDomain = computeDomain(this.stateObj);
|
||||
const stateDomain = computeStateDomain(this.stateObj);
|
||||
let serviceDomain;
|
||||
let service;
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||
import '../../util/hass-mixins.js';
|
||||
import '../ha-label-badge.js';
|
||||
|
||||
import computeDomain from '../../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain.js';
|
||||
import computeStateName from '../../../js/common/entity/compute_state_name.js';
|
||||
import domainIcon from '../../../js/common/entity/domain_icon.js';
|
||||
import stateIcon from '../../../js/common/entity/state_icon.js';
|
||||
@ -97,13 +97,13 @@ class HaStateLabelBadge extends
|
||||
}
|
||||
|
||||
computeClassNames(state) {
|
||||
const classes = [computeDomain(state)];
|
||||
const classes = [computeStateDomain(state)];
|
||||
classes.push(attributeClassNames(state, ['unit_of_measurement']));
|
||||
return classes.join(' ');
|
||||
}
|
||||
|
||||
computeValue(localize, state) {
|
||||
const domain = computeDomain(state);
|
||||
const domain = computeStateDomain(state);
|
||||
switch (domain) {
|
||||
case 'binary_sensor':
|
||||
case 'device_tracker':
|
||||
@ -125,7 +125,7 @@ class HaStateLabelBadge extends
|
||||
if (state.state === 'unavailable') {
|
||||
return null;
|
||||
}
|
||||
const domain = computeDomain(state);
|
||||
const domain = computeStateDomain(state);
|
||||
switch (domain) {
|
||||
case 'alarm_control_panel':
|
||||
if (state.state === 'pending') {
|
||||
@ -162,7 +162,7 @@ class HaStateLabelBadge extends
|
||||
}
|
||||
|
||||
computeLabel(localize, state, _timerTimeRemaining) {
|
||||
const domain = computeDomain(state);
|
||||
const domain = computeStateDomain(state);
|
||||
if (state.state === 'unavailable' ||
|
||||
['device_tracker', 'alarm_control_panel'].includes(domain)) {
|
||||
// Localize the state with a special state_badge namespace, which has variations of
|
||||
@ -194,7 +194,7 @@ class HaStateLabelBadge extends
|
||||
|
||||
startInterval(stateObj) {
|
||||
this.clearInterval();
|
||||
if (computeDomain(stateObj) === 'timer') {
|
||||
if (computeStateDomain(stateObj) === 'timer') {
|
||||
this.calculateTimerRemaining(stateObj);
|
||||
|
||||
if (stateObj.state === 'active') {
|
||||
|
@ -8,7 +8,7 @@ import '../cards/ha-badges-card.js';
|
||||
import '../cards/ha-card-chooser.js';
|
||||
import './ha-demo-badge.js';
|
||||
|
||||
import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../js/common/entity/compute_state_domain.js';
|
||||
|
||||
{
|
||||
// mapping domain to size of the card.
|
||||
@ -247,7 +247,7 @@ import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
let size = 0;
|
||||
|
||||
entities.forEach((entity) => {
|
||||
const domain = computeDomain(entity);
|
||||
const domain = computeStateDomain(entity);
|
||||
|
||||
if (domain in DOMAINS_WITH_CARD) {
|
||||
owncard.push(entity);
|
||||
@ -275,7 +275,7 @@ import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
owncard.forEach((entity) => {
|
||||
cards.columns[curIndex].push({
|
||||
hass: hass,
|
||||
cardType: computeDomain(entity),
|
||||
cardType: computeStateDomain(entity),
|
||||
stateObj: entity,
|
||||
});
|
||||
});
|
||||
@ -295,7 +295,7 @@ import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
|
||||
Object.keys(splitted.ungrouped).forEach((key) => {
|
||||
const state = splitted.ungrouped[key];
|
||||
const domain = computeDomain(state);
|
||||
const domain = computeStateDomain(state);
|
||||
|
||||
if (domain === 'a') {
|
||||
cards.demo = true;
|
||||
|
@ -5,7 +5,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||
import '../util/hass-mixins.js';
|
||||
|
||||
import computeStateName from '../../js/common/entity/compute_state_name.js';
|
||||
import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../js/common/entity/compute_state_domain.js';
|
||||
import computeStateDisplay from '../../js/common/entity/compute_state_display.js';
|
||||
|
||||
{
|
||||
@ -59,7 +59,7 @@ import computeStateDisplay from '../../js/common/entity/compute_state_display.js
|
||||
identifier: lineChartDevices[unit].map(states => states[0].entity_id).join(''),
|
||||
data: lineChartDevices[unit].map((states) => {
|
||||
const last = states[states.length - 1];
|
||||
const domain = computeDomain(last);
|
||||
const domain = computeStateDomain(last);
|
||||
return {
|
||||
domain: domain,
|
||||
name: computeStateName(last),
|
||||
|
@ -8,7 +8,7 @@ import '../util/hass-mixins.js';
|
||||
import './more-info/more-info-controls.js';
|
||||
import './more-info/more-info-settings.js';
|
||||
|
||||
import computeDomain from '../../js/common/entity/compute_domain';
|
||||
import computeStateDomain from '../../js/common/entity/compute_state_domain';
|
||||
import isComponentLoaded from '../../js/common/config/is_component_loaded.js';
|
||||
|
||||
class HaMoreInfoDialog extends window.hassMixins.DialogMixin(PolymerElement) {
|
||||
@ -116,7 +116,7 @@ class HaMoreInfoDialog extends window.hassMixins.DialogMixin(PolymerElement) {
|
||||
}
|
||||
|
||||
_computeDomain(stateObj) {
|
||||
return stateObj ? computeDomain(stateObj) : '';
|
||||
return stateObj ? computeStateDomain(stateObj) : '';
|
||||
}
|
||||
|
||||
_computeStateObj(hass) {
|
||||
|
@ -4,7 +4,7 @@ import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||
|
||||
import '../../../state-summary/state-card-content.js';
|
||||
|
||||
import computeDomain from '../../../../js/common/entity/compute_domain';
|
||||
import computeStateDomain from '../../../../js/common/entity/compute_state_domain';
|
||||
import dynamicContentUpdater from '../../../../js/common/dom/dynamic_content_updater.js';
|
||||
import stateMoreInfoType from '../../../../js/common/entity/state_more_info_type.js';
|
||||
|
||||
@ -73,7 +73,7 @@ class MoreInfoGroup extends PolymerElement {
|
||||
|
||||
if (states && states.length > 0) {
|
||||
const baseStateObj = states.find(s => s.state === 'on') || states[0];
|
||||
const groupDomain = computeDomain(baseStateObj);
|
||||
const groupDomain = computeStateDomain(baseStateObj);
|
||||
|
||||
// Groups need to be filtered out or we'll show content of
|
||||
// first child above the children of the current group
|
||||
@ -84,7 +84,7 @@ class MoreInfoGroup extends PolymerElement {
|
||||
});
|
||||
|
||||
for (let i = 0; i < states.length; i++) {
|
||||
if (groupDomain !== computeDomain(states[i])) {
|
||||
if (groupDomain !== computeStateDomain(states[i])) {
|
||||
groupDomainStateObj = false;
|
||||
break;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import '../../util/hass-mixins.js';
|
||||
import './controls/more-info-content.js';
|
||||
|
||||
import computeStateName from '../../../js/common/entity/compute_state_name.js';
|
||||
import computeDomain from '../../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../../js/common/entity/compute_state_domain.js';
|
||||
import isComponentLoaded from '../../../js/common/config/is_component_loaded.js';
|
||||
import { DOMAINS_MORE_INFO_NO_HISTORY } from '../../../js/common/const.js';
|
||||
|
||||
@ -121,17 +121,17 @@ import { DOMAINS_MORE_INFO_NO_HISTORY } from '../../../js/common/const.js';
|
||||
}
|
||||
|
||||
_computeShowStateInfo(stateObj) {
|
||||
return !stateObj || !DOMAINS_NO_INFO.includes(computeDomain(stateObj));
|
||||
return !stateObj || !DOMAINS_NO_INFO.includes(computeStateDomain(stateObj));
|
||||
}
|
||||
|
||||
_computeShowHistoryComponent(hass, stateObj) {
|
||||
return hass && stateObj &&
|
||||
isComponentLoaded(hass, 'history') &&
|
||||
!DOMAINS_MORE_INFO_NO_HISTORY.includes(computeDomain(stateObj));
|
||||
!DOMAINS_MORE_INFO_NO_HISTORY.includes(computeStateDomain(stateObj));
|
||||
}
|
||||
|
||||
_computeDomain(stateObj) {
|
||||
return stateObj ? computeDomain(stateObj) : '';
|
||||
return stateObj ? computeStateDomain(stateObj) : '';
|
||||
}
|
||||
|
||||
_computeStateName(stateObj) {
|
||||
|
@ -7,7 +7,6 @@ import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
||||
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
||||
|
||||
import '../components/ha-sidebar.js';
|
||||
import '../dialogs/ha-more-info-dialog.js';
|
||||
import '../dialogs/ha-voice-command-dialog.js';
|
||||
import '../util/ha-url-sync.js';
|
||||
import '../util/hass-mixins.js';
|
||||
|
@ -17,7 +17,7 @@ import '../util/hass-mixins.js';
|
||||
import './ha-app-layout.js';
|
||||
|
||||
import computeStateName from '../../js/common/entity/compute_state_name.js';
|
||||
import computeDomain from '../../js/common/entity/compute_domain.js';
|
||||
import computeStateDomain from '../../js/common/entity/compute_state_domain.js';
|
||||
import computeLocationName from '../../js/common/config/location_name.js';
|
||||
|
||||
{
|
||||
@ -315,7 +315,7 @@ import computeLocationName from '../../js/common/config/location_name.js';
|
||||
entityIds.forEach((entityId) => {
|
||||
const state = hass.states[entityId];
|
||||
|
||||
if (ALWAYS_SHOW_DOMAIN.includes(computeDomain(state))) {
|
||||
if (ALWAYS_SHOW_DOMAIN.includes(computeStateDomain(state))) {
|
||||
states[entityId] = state;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user