diff --git a/src/standard-configuration/climate.ts b/src/standard-configuration/climate.ts index dcd9df03..92c0a21a 100755 --- a/src/standard-configuration/climate.ts +++ b/src/standard-configuration/climate.ts @@ -1,6 +1,6 @@ import { levelVariable, listVariable } from '../actionVariables'; import { ActionConfig } from '../types'; -import { HomeAssistant, LocalizeFunc } from 'custom-card-helpers'; +import { computeStateDisplay, HomeAssistant, LocalizeFunc } from 'custom-card-helpers'; import { HassEntity } from 'home-assistant-js-websocket'; import { localize } from '../localize/localize'; @@ -194,3 +194,48 @@ export const climateActions = ( return actions; }; + + +export const climateStates = (hass: HomeAssistant, stateObj: HassEntity) => { + const modeList = [ + { + value: 'off', + icon: 'hass:power-off', + name: hass.localize('state.climate.off'), + }, + { + value: 'heat', + icon: 'hass:fire', + name: hass.localize('state.climate.heat'), + }, + { + value: 'cool', + icon: 'hass:snowflake', + name: hass.localize('state.climate.cool'), + }, + { + value: 'heat_cool', + icon: 'hass:thermometer', + name: hass.localize('state.climate.heat_cool'), + }, + { + value: 'auto', + icon: 'hass:autorenew', + name: hass.localize('state_attributes.climate.auto'), + }, + { + value: 'dry', + icon: 'hass:water-percent', + name: hass.localize('state.climate.dry'), + }, + { + value: 'fan_only', + icon: 'hass:fan', + name: hass.localize('state.climate.fan_only'), + }, + ]; + if (stateObj && stateObj.attributes.hvac_modes && Array.isArray(stateObj.attributes.hvac_modes)) { + return modeList.filter(e => stateObj.attributes.hvac_modes.includes(e.value)); + } + return modeList; +}; \ No newline at end of file diff --git a/src/standard-configuration/light.ts b/src/standard-configuration/light.ts index 0926f847..ec31b009 100755 --- a/src/standard-configuration/light.ts +++ b/src/standard-configuration/light.ts @@ -1,7 +1,7 @@ import { HassEntity } from 'home-assistant-js-websocket'; import { levelVariable } from '../actionVariables'; import { ActionConfig } from '../types'; -import { HomeAssistant } from 'custom-card-helpers'; +import { computeStateDisplay, HomeAssistant } from 'custom-card-helpers'; import { localize } from '../localize/localize'; export const lightActions = (hass: HomeAssistant, stateObj?: HassEntity): ActionConfig[] => { @@ -39,3 +39,17 @@ export const lightActions = (hass: HomeAssistant, stateObj?: HassEntity): Action return actions; }; + + +export const lightStates = (hass: HomeAssistant, stateObj: HassEntity) => [ + { + value: "off", + name: computeStateDisplay(hass.localize, { ...stateObj, state: "off" }, hass.language), + icon: "hass:lightbulb-off" + }, + { + value: "on", + name: computeStateDisplay(hass.localize, { ...stateObj, state: "on" }, hass.language), + icon: "hass:lightbulb" + } +]; \ No newline at end of file diff --git a/src/standard-configuration/standardStates.ts b/src/standard-configuration/standardStates.ts index a57e02c6..7a8f2366 100755 --- a/src/standard-configuration/standardStates.ts +++ b/src/standard-configuration/standardStates.ts @@ -7,6 +7,8 @@ import { inputBooleanStates } from './input_boolean'; import { switchStates } from './switch'; import { personStates } from './person'; import { fanStates } from './fan'; +import { lightStates } from './light'; +import { climateStates } from './climate'; export function standardStates(entity_id: string, hass: HomeAssistant) { const domain = computeDomain(entity_id); @@ -17,6 +19,8 @@ export function standardStates(entity_id: string, hass: HomeAssistant) { return alarmControlPanelStates(hass, stateObj); case 'binary_sensor': return binarySensorStates(hass, stateObj); + case 'climate': + return climateStates(hass, stateObj); case 'cover': return coverStates(hass, stateObj); case 'fan': @@ -25,6 +29,8 @@ export function standardStates(entity_id: string, hass: HomeAssistant) { return inputBooleanStates(hass, stateObj); case 'switch': return switchStates(hass, stateObj); + case 'light': + return lightStates(hass, stateObj); case 'lock': return lockStates(hass, stateObj); case 'person':