diff --git a/panels/config/customize/ha-config-customize.html b/panels/config/customize/ha-config-customize.html
index b6e2472741..53d51658a3 100644
--- a/panels/config/customize/ha-config-customize.html
+++ b/panels/config/customize/ha-config-customize.html
@@ -32,7 +32,7 @@
Customization
Tweak per-entity attributes.
- Added/edited customizations will take effect immidiately. Removed customizations will take effect when the entity is updated.
+ Added/edited customizations will take effect immediately. Removed customizations will take effect when the entity is updated.
{
if (attr.closed || attr.secondary || !attr.attribute || !attr.value) return;
- data[attr.attribute] = (attr.type === 'json' ? JSON.parse(attr.value) : attr.value);
+ const value = attr.type === 'json' ? JSON.parse(attr.value) : attr.value;
+ if (!value) return;
+ data[attr.attribute] = value;
});
const objectId = this.entity.entity_id;
@@ -213,7 +215,11 @@ class HaFormCustomize extends Polymer.Element {
getNewAttributesOptions(localAttributes, globalAttributes, existingAttributes, newAttributes) {
const knownKeys =
Object.keys(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES)
- .filter(key => window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[key])
+ .filter((key) => {
+ const conf = window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[key];
+ return conf && (!conf.domains || !this.entity ||
+ conf.domains.includes(window.hassUtil.computeDomain(this.entity)));
+ })
.filter(this.filterFromAttributes(localAttributes))
.filter(this.filterFromAttributes(globalAttributes))
.filter(this.filterFromAttributes(existingAttributes))
diff --git a/panels/config/customize/types/ha-customize-array.html b/panels/config/customize/types/ha-customize-array.html
index f92c6a633e..b1b9ee4507 100644
--- a/panels/config/customize/types/ha-customize-array.html
+++ b/panels/config/customize/types/ha-customize-array.html
@@ -44,13 +44,8 @@ class HaCustomizeArray extends window.hassMixins.EventsMixin(Polymer.Element) {
}
getOptions(item) {
- const domain = item.domain;
- if (!domain) {
- this.item.type = 'string';
- this.fire('item-changed');
- return [];
- }
- const options = item.options[domain];
+ const domain = item.domain || '*';
+ const options = item.options[domain] || item.options['*'];
if (!options) {
this.item.type = 'string';
this.fire('item-changed');
diff --git a/src/util/hass-attributes-util.js b/src/util/hass-attributes-util.js
index 7b49262e39..01730539d3 100644
--- a/src/util/hass-attributes-util.js
+++ b/src/util/hass-attributes-util.js
@@ -24,27 +24,27 @@ window.hassAttributeUtil.TYPE_TO_TAG = {
// 1) Any key of this object won't be shown in more-info window.
// 2) Any key which has value other than undefined will appear in customization
// config according to its value.
-// TODO: Allow per-domain config, as some attributes are only relevant for some
-// domains.
-window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES = {
- entity_picture: undefined,
- friendly_name: { type: 'string', description: 'Name' },
- icon: { type: 'icon' },
- emulated_hue: { type: 'boolean' },
- emulated_hue_name: { type: 'string' },
- haaska_hidden: undefined,
- haaska_name: undefined,
- homebridge_hidden: { type: 'boolean' },
- homebridge_name: { type: 'string' },
- supported_features: undefined,
- attribution: undefined,
- custom_ui_state_card: { type: 'string' },
- device_class: {
- type: 'array',
- options: window.hassAttributeUtil.DOMAIN_DEVICE_CLASS,
- description: 'Device class' },
- hidden: { type: 'boolean', description: 'Hide from UI' },
- assumed_state: { type: 'boolean' },
- initial_state: { type: 'string' },
- unit_of_measurement: { type: 'string' },
-};
+window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES =
+ window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES || {
+ entity_picture: undefined,
+ friendly_name: { type: 'string', description: 'Name' },
+ icon: { type: 'icon' },
+ emulated_hue: { type: 'boolean' },
+ emulated_hue_name: { type: 'string' },
+ haaska_hidden: undefined,
+ haaska_name: undefined,
+ homebridge_hidden: { type: 'boolean' },
+ homebridge_name: { type: 'string' },
+ supported_features: undefined,
+ attribution: undefined,
+ custom_ui_state_card: { type: 'string' },
+ device_class: {
+ type: 'array',
+ options: window.hassAttributeUtil.DOMAIN_DEVICE_CLASS,
+ description: 'Device class',
+ domains: ['binary_sensor', 'cover'] },
+ hidden: { type: 'boolean', description: 'Hide from UI' },
+ assumed_state: { type: 'boolean' },
+ initial_state: { type: 'string' },
+ unit_of_measurement: { type: 'string' },
+ };