Skip to content
This repository has been archived by the owner on May 28, 2022. It is now read-only.

Commit

Permalink
Add support for sub_attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Oct 20, 2018
1 parent 3715bbc commit fc8533f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions state-attribute-element.js
Expand Up @@ -4,11 +4,15 @@ class StateAttributeElement extends HTMLElement {
const prefix_string = this.config.prefix || ''
const suffix_string = this.config.suffix || ''
const show_empty = this.config.show_empty
const attr = this.config.attribute;
const state = hass.states[entityId].attributes[attr];
const attr = this.config.attribute
const sub_attribute = this.config.sub_attribute || ''
this.state = hass.states[entityId].attributes[attr]
if (this.config.sub_attribute) {
this.state = hass.states[entityId].attributes[attr][sub_attribute]
}
const card = document.createElement('state-attribute-element');
if (state.length != 0 || show_empty === true) {
this.innerHTML = `${prefix_string}${state}${suffix_string}`
if (this.state.length != 0 || show_empty === true) {
this.innerHTML = `${prefix_string}${this.state}${suffix_string}`
}
}
setConfig(config) {
Expand Down

0 comments on commit fc8533f

Please sign in to comment.