Skip to main content

Feature

The feature service contains utilities for interacting with Home Assistant's entity supported features from within typescript. Feature flags for entities arrive as a supported_features attribute, attached as a number.

In order to decode this number, bit shifting operations and a reference table for values needs to be on hand.

methoddescription
createSupportedFeaturesprovide an array of features, will returns a number representation
getSupportedFeaturesTakes in an entity (proxy / id) or supported features, returns array of features
hasFeatureUsed to test if a particlar entity has a feature
listEntityFeaturesReturns an array of string features for an entity
import { TServiceParams } from "@digital-alchemy/core";

export function ExampleService({ hass, lifecycle }: TServiceParams) {
lifecycle.onReady(() => {
const features = listEntityFeatures("light.example_hue_light");
// features = ["EFFECT", "FLASH", "TRANSITION"]
});
}