Skip to content
Jon Hall edited this page May 19, 2018 · 10 revisions

Description

Actor resources are heaters, pumps, power outlets--anything that you might want to assign a power percentage, an on/off state to, and control via your RaspberryPi's GPIO pins.

Methods

Method Param Return Type Description
getActorTypes n/a Promise Fetches a list of all available actor types/properties.
getActors n/a Promise Fetches a list of all available Actor resources.
createActor Actor Promise Creates an actor with the given values.
onUpdate Function Unsubscribe function A way to register for updates to any of the instances of a given resource.
setTimer (actor, seconds) Promise Toggles the timer state on a given actor for a given number of seconds.

Actor Resource

This is the collection of settings that represent an Actor resource. Below is the best estimation of what an Actor's settings do, in some instances their uses are opaque even to Swill.

Property Type Value Range Description
config Object n/a An object of configurable properties based on the actor type.
hide Number 0|1 Hide the actor on the dashboard.
id Number Not Editable The unique identifier for the actor.
instance Number Not Editable ???
name String * The label for the actor.
power Number [1-100] A power percentage for the actor.
state Number 0|1 The on/off state for the actor. 0 is off, 1 is on.
timer Timestamp e.g. 1526364819 If this parameter is set, CraftBeerPi will keep the actor state 1 (on) until the time runs past the timestamp
type String Dummy|GPIOPWM|GPIOSimple|RelayBoard The type of actor.

For information on basic usage of resource instances, go to Interacting with Resources.

Types

Note: the full type objects returned from the SDK contain more configuration than is visible in the following table.

Type Config Properties Description
Dummy None A dummy actor type, for example purposes.
GPIOPWM { frequency: Number, gpio: [0-27] } GPIO control with added PWM modulation.
GPIOSimple { gpio: [0-27] } Simple GPIO control.
RelayBoard { gpio: [0-27] } Relay board control via GPIO.

Events

You can subscribe to all actor events using the onUpdate function.

Possible Actor events:

  • UPDATE_ACTOR
  • SWITCH_ACTOR
  • DELETE_ACTOR

For more information on how to receive and act on these events, go to Receiving Updates to Instances of Resources.

Clone this wiki locally