mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-01 14:36:35 +00:00

* Move featureClassNames to js util * Add tests for featureClassNames * Strip empty feature class names * Move canToggleDomain to js util * Add tests for canToggleDomain * Refactor canToggleDomain to ensure boolean return * Switch to chai assert for richer syntax options * Move canToggleState to js util * Tests for canToggleState * Enable linting for mocha tests * Move stateCardType to js util * Add tests for stateCardType * Move stateMoreInfoType to js util * Tests for stateMoreInfoType * Include mdn Array includes polyfill
12 lines
358 B
JavaScript
12 lines
358 B
JavaScript
import canToggleDomain from './can_toggle_domain.js';
|
|
import computeStateDomain from './compute_state_domain.js';
|
|
|
|
export default function canToggleState(hass, stateObj) {
|
|
const domain = computeStateDomain(stateObj);
|
|
if (domain === 'group') {
|
|
return stateObj.state === 'on' || stateObj.state === 'off';
|
|
}
|
|
|
|
return canToggleDomain(hass, domain);
|
|
}
|