action

A generic block that represents some kind of action

Name action
Type Function
Path packages/blocks/src/building-blocks/action.ts

Example

      
import { action } from "@hass-blocks/blocks"

const turnOnLivingRoomLights = action({
  name: `Turn on lights`,
  callback: async (hass) => {
     await hass.callService({
       domain: 'light',
       service: 'turn_on',
       target: {
         entity_id: 'light.living_room'
       }
     })
  },
});
 

Signature

    action: <I = void, O = void>(config: IActionConfig<I, O>) => Block<I, O> 

Parameters

Name Type Description
config IActionConfig<I, O> configuration for the action

Return Value

Block<I, O>