1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-05-08 17:28:46 +01:00

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
+3
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);
}
@@ -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));
});
});