Home Page

@hass-blocks/blocks

A declarative framework for building Home Assistant automations

Function

NameDescription
actionA generic block that represents some kind of action
assertionAn assertion is a block which can decide whether or not an automation should continue based on the result of a predicate
automationAn automation represents a sequence of actions that can either be executed in sequence or in parallel. When passed into
concurrentlyWhen executed, this block will execute all the blocks passed in as the first argument concurrently. Once complete the outputs from all the blocks will be returned as an array
initialiseBlocksBootstrap the connection with Home Assistant and initialise Hass Blocks
sequenceBlock that takes a series of blocks and executes them either in sequence or in parallel
serviceCallA specialised action block that will call a service on your configured Home Assistant instance
triggerAssociate the automation with a Home Assistant trigger. For more details, see
whenUse in combination with an , block to implement branching logic in your automations. Supply two blocks and execute either one of them depending on the result of the assertion

Class

NameDescription
BlockThe core Hass Blocks abstraction - all Blocks must extend from this class for the framework to be able to execute them

Enum

NameDescription
ExecutionModeThe execution mode for an automation

Interface

NameDescription
AutomationRegisteredAn event that is emitted when an automation has been registered
BaseHassEventThe base event for all events related to automations emitted by this framework
BlockFailedAn event that is emitted when a block fails for some reason
BlockFinishedAn event that is emitted when a block finishes successfully
BlockPendingAn event that is emitted when a block is queued for execution
BlockStartedAn event that is emitted when a block starts executing
ConditionResultOutput returned when a conditional block signals to continue
ContinueOutputOutput returned when a block signals to continue
GeneralFailureAn event that is emitted when there is some kind of error
IActionConfigConfiguration object for action blocks
IAssertionConfigConfiguration object for an assertion block
IAutomationConfigConfiguration object for automation blocks
IBaseBlockConfigConfiguration that is common for all blocks
IBlockThe abstract base class that all blocks inherit from
IBlocksConfigConfiguration object for Hass Blocks
IBlocksConnectionAn initialied Hass Blocks connection
IBlocksPluginAn object that implements this interface can be passed into the 'plugins' property of the , config object.
IBlocksRegistryA blocks registery object - this is where you start registering automations
ICallServiceParamsParameters for calling Home Assistant services
IEventBusThe Hass Blocks internal event bus
IfThenElseConditionConfigConfiguration object for a condition block
IFullBlocksClientThe full version of the blocks client - only available to plugins
IHassAn initialised Home Assistant connection that blocks can used to inspect state or make calls to services
IPluginArgsThis object will be passed into the load method once during Hass Blocks initialisation, plugins can use it to interact with home assistant and listen to hass blocks event
ITriggerAn object representing a Home Assistant trigger
ITriggerConfigThe configuration object for a trigger
LoadPluginFinishedAn event that is emitted just after a specific plugin finishes loading
LoadPluginsFinishedAn event that is emitted after all plugins have finished loading
LoadPluginsStartAn event that is emitted just before all plugins start loading
LoadPluginStartAn event that is emitted just before a specific plugin starts loading
LogEventAn event emitted whenever you want to log information. Will be picked up by logging clients
SequenceAbortedAn event that is emitted when a sequence is aborted for some reason
SerialisedBlockA serialised version of a block - used for transmission purposes
StateChangedAn event that is emitted when the websocket client recieves a state change from Hass
StopOutputOutput returned when a block signals to stop

TypeAlias

NameDescription
BlockOutputResults that can be returned by blocks
BlockRetainTypeRehydrate a sequence of blocks with its input and output types
GetSequenceInputGiven an array of blocks, get the input type from the first block
GetSequenceOutputGiven an array of blocks, get the output type from the last block
HassBlocksEventEvents published by the framework on the event bus
HassContextThe Home Assistant context (See ,)
HassEntityA Home Assistant entity
HassEntityAttributeBaseThe core entity attributes shared by all Home Assistant entities
HassEntityBaseThe core attributes shared by all Home Assistant entities
InputTypeGiven a block, extract the input type
OutputTypeGiven a block, extract the output type
OutputTypeKeepPromiseBlock output type without undefined
ValidInputOutputSequenceGiven an Input and Ouput type and an array of block types, this type validates that they are a compatible sequence of blocks.,So for input I, output O and blocks A and B, this type will produce compiler errors unless I is compatible with A,, A, is compatible with B, and B, is compatible with O
>