UNPKG

custom-card-helpers

Version:

Set of helpful functions and types for Custom Card creators

12 lines (10 loc) 350 B
import { STATES_OFF } from "./const"; import { turnOnOffEntity } from "./turn-on-off-entity"; import { HomeAssistant } from "./types"; export const toggleEntity = ( hass: HomeAssistant, entityId: string ): Promise<void> => { const turnOn = STATES_OFF.includes(hass.states[entityId].state); return turnOnOffEntity(hass, entityId, turnOn); };