diff --git a/src/cards/ha-weather-card.html b/src/cards/ha-weather-card.html index bc95083325..49c2dbbfc9 100644 --- a/src/cards/ha-weather-card.html +++ b/src/cards/ha-weather-card.html @@ -14,23 +14,29 @@ } .attribution { - color:grey; + color: var(--secondary-text-color); + text-align: right; }
- \ No newline at end of file +}()); + diff --git a/src/more-infos/more-info-default.html b/src/more-infos/more-info-default.html index 92f4f375e8..19a6772d56 100644 --- a/src/more-infos/more-info-default.html +++ b/src/more-infos/more-info-default.html @@ -9,15 +9,21 @@ .data-entry .value { max-width: 200px; } + + .attribution { + color: var(--secondary-text-color); + text-align: right; + }
+
[[computeAttribution(stateObj)]]
@@ -29,7 +35,7 @@ var FILTER_KEYS = [ 'entity_picture', 'friendly_name', 'icon', 'unit_of_measurement', 'emulated_hue', 'emulated_hue_name', 'haaska_hidden', 'haaska_name', - 'homebridge_hidden', 'homebridge_name', + 'homebridge_hidden', 'homebridge_name', 'attribution', ]; Polymer({ @@ -42,22 +48,19 @@ }, computeDisplayAttributes: function (stateObj) { - if (!stateObj) { - return []; - } - - return Object.keys(stateObj.attributes).filter( - function (key) { return FILTER_KEYS.indexOf(key) === -1; }); + return window.hassUtil.computeDisplayAttributes(stateObj, FILTER_KEYS); }, formatAttribute: function (attribute) { - return attribute.replace(/_/g, ' '); + return window.hassUtil.formatAttribute(attribute); }, - getAttributeValue: function (stateObj, attribute) { - var value = stateObj.attributes[attribute]; + formatAttributeValue: function (stateObj, attribute) { + return window.hassUtil.formatAttributeValue(stateObj, attribute); + }, - return Array.isArray(value) ? value.join(', ') : value; + computeAttribution: function (stateObj) { + return window.hassUtil.computeAttribution(stateObj); }, }); }()); diff --git a/src/util/hass-util.html b/src/util/hass-util.html index 5d69ca2756..73b7f21244 100644 --- a/src/util/hass-util.html +++ b/src/util/hass-util.html @@ -341,4 +341,27 @@ window.hassUtil.stateIcon = function (state) { return window.hassUtil.domainIcon(state.domain, state.state); }; +window.hassUtil.computeDisplayAttributes = function (stateObj, filterKeys) { + if (!stateObj) { + return []; + } + + return Object.keys(stateObj.attributes).filter( + function (key) { return filterKeys.indexOf(key) === -1; }); +}; + +window.hassUtil.formatAttribute = function (attribute) { + return attribute.replace(/_/g, ' '); +}; + +window.hassUtil.formatAttributeValue = function (stateObj, attribute) { + var value = stateObj.attributes[attribute]; + + return Array.isArray(value) ? value.join(', ') : value; +}; + +window.hassUtil.computeAttribution = function (stateObj) { + return stateObj.attributes.attribution; +}; +