Been studying a lot of custom state card examples, and I get (I think) most of it enough to modify/cobble together the html/javascript to do what I want to do.
However, I don’t really understand the Polymer section, and how to pass entities in. For instance, these two state cards are doing seemingly different things in this section.
Polymer({
is: 'custom-weather-card',
properties: {
hass: {
type: Object,
},
stateObj: {
type: Object,
},
weatherObj: {
type: Object,
observer: 'checkRequirements',
computed: 'comptuteWeatherObj(hass, stateObj)',
},
},
comptuteWeatherObj: function (hass, stateObj) {
return stateObj && stateObj.attributes && stateObj.attributes.config && stateObj.attributes.config.weather ? hass.states[stateObj.attributes.config.weather] : null;
},
class StateCardHTML extends window.hassMixins.EventsMixin(Polymer.Element) {
static get is() { return 'state-card-html'; }
static get properties() {
return {
hass: Object,
stateObj: Object,
config: {
type: Object,
computed: 'computeConfig(stateObj)',
},
};
}
static get observers() {
return [
'contentChanged(hass.states.*, config)'
]
}
computeConfig(stateObj) {
return stateObj && stateObj.attributes && stateObj.attributes.config;
}
These polymer functions are declared quite differently. And the “computerConfig” or “computeWeatherObj” part I don’t quite understand, I know its passing the entity from hass into polymer, but I don’t understand the syntax.
I guess my question is mainly, if I want to pass in a few entities, or even an array of entities (the second code block is sorta doing that), how do I go about structuring the polymer function?