I am trying to use multiple entities in a custom google chart state card. However, I suck at Polymer.
I’ve read a bit, but I simply don’t get it. Probably I am missing something small.
Starting from the standard example below, how could I retrieve and use the state or attribute of a secondary entity (or more) in the same state card/script (e.g. calculating something inside the script - the average brightness of two light bulbs)?
@andrey has a bunch of examples in his CustomUI git, but they are quite complex and I fail to understand.
Thank you in advance.
homeassistant:
customize:
light.bedroom:
custom_ui_state_card: state-card-my-custom-light
frontend:
extra_html_url:
- /local/custom_ui/state-card-my-custom-light.html
<dom-module id='state-card-my-custom-light'>
<template>
<style>
</style>
<textarea>[[_toStr(StateObj)]]</textarea>
</template>
</dom-module>
<script>
class StateCardMyCustomLight extends Polymer.Element {
static get is() { return 'state-card-my-custom-light'; }
static get properties() {
return {
// Home Assistant object
hass: Object,
// inDialog is true if shown as more-info-card
inDialog: {
type: Boolean,
value: false,
},
// includes state, config and more information of the entity
stateObj: Object,
};
}
_toStr(obj) {
return JSON.stringify(obj);
}
}
customElements.define(StateCardMyCustomLight.is, StateCardMyCustomLight);
</script>