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:
@@ -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));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user