I’m playing around with a function that returns an animated or stationary image for the background based on whether a fan is on or not.
If I use entity.state for comparison, it changes the background images as soon as I change the fan mode. This won’t work with the input_select because I need to base the background image on the state or attribute of another entity and input_select has no attributes that can be set.
entity.state code:
{
position: [2, 1],
type: TYPES.INPUT_SELECT,
id: 'input_select.family_room_thermostat_fan_mode',
title: 'Family Room',
bg: function (item, entity) {
return (entity.state == 'Auto Low' ? '/tileboard/images/fan5_off.gif' : '/tileboard/images/fan5_on.gif');
},
state: function (item, entity) {
return (this.states['climate.family_room_thermostat'].attributes.fan_action);
},
},
If I use this.states, the background image never changes unless I refresh the page. The state function, which uses the same this.states[‘climate.family_room_thermostat’].attributes.fan_action, updates properly when the fan mode is changed and the fan turns off or on (Idle or Running).
this.states code:
{
position: [2, 1],
type: TYPES.INPUT_SELECT,
id: 'input_select.family_room_thermostat_fan_mode',
title: 'Family Room',
bg: function (item, entity) {
return (this.states['climate.family_room_thermostat'].attributes.fan_action == 'Idle' ? '/tileboard/images/fan5_off.gif' : '/tileboard/images/fan5_on.gif');
},
state: function (item, entity) {
return (this.states['climate.family_room_thermostat'].attributes.fan_action);
},
},
Any ideas as to what the problem may be or any suggestions for alternate ways to accomplish this?