i-block

The abstract base class that all blocks inherit from

Name i-block
Type Interface
Path packages/blocks/src/types/i-block.ts

Properties

Name Type Description
id string String to identify this particular instance of a block. Must be unique
inputType I | undefined There is no reason to actually use this property. It exists as a typescript hack in order to allow the type of a subclass to be inferred from the abstract version
name string Friendly name for the block - for use in user interfaces
outputType O | undefined There is no reason to actually use this property. It exists as a typescript hack in order to allow the type of a subclass to be inferred from the abstract version
trigger ITrigger | ITrigger[] Triggers that are currently registered with this block
typeString string String that identifies the kind of block

Methods

run

Called by the framework when the block is executed

Signature
    run(hass: IHass, input: I, events?: IEventBus, triggerId?: string): Promise<BlockOutput<O>> | BlockOutput<O>; 
Parameters
Name Type Description
hass IHass
input I The input for this block - usually the output from the last one
events IEventBus An initialised event bus
triggerId string a uuid trigger id, unique to this particular trigger sequence
Return Value
Promise<BlockOutput<O>> | BlockOutput<O>

toJson

A JSON representation of the block. Used for websocket and rest serialisation

Signature
    toJson(): SerialisedBlock; 
Return Value
SerialisedBlock

validate

If defined, this method will be called when the parent automation is registered. If any configuration is invalid, an error should be thrown

Signature
    validate(client: IHass): Promise<void>; 
Parameters
Name Type Description
client IHass
Return Value
Promise<void>