Update canToggleState with toggleable climate (#782)

This commit is contained in:
Andrey 2018-01-05 09:57:23 +02:00 committed by Paulus Schoutsen
parent 1d13126bb5
commit 0b9bd62251
2 changed files with 20 additions and 0 deletions

View File

@ -6,6 +6,9 @@ export default function canToggleState(hass, stateObj) {
if (domain === 'group') {
return stateObj.state === 'on' || stateObj.state === 'off';
}
if (domain === 'climate') {
return !!((stateObj.attributes || {}).supported_features & 4096);
}
return canToggleDomain(hass, domain);
}

View File

@ -37,4 +37,21 @@ describe('canToggleState', () => {
};
assert.isFalse(canToggleState(hass, stateObj));
});
it('Detects climate with toggle', () => {
const stateObj = {
entity_id: 'climate.bla',
attributes: {
supported_features: 4096,
},
};
assert.isTrue(canToggleState(hass, stateObj));
});
it('Detects climate without toggle', () => {
const stateObj = {
entity_id: 'climate.bla',
};
assert.isFalse(canToggleState(hass, stateObj));
});
});