public final class Scene
- Object
- Scene
A named set of accessory states that can be applied in one go: HomeKit’s
HMActionSet, a Google Home scene.
Run one with SmartHome.executeScene(Scene).
Scenes, and not automations
A scene is a list of things to set. An automation is a scene plus a
trigger – a time, a sensor crossing a threshold, someone arriving – and
the three ecosystems model triggers in three incompatible ways: HomeKit has
HMTimerTrigger, HMEventTrigger and HMCharacteristicThreshold, Google
has its own automations language, and Matter has nothing at all. There is
no honest common shape, so this release exposes scenes and
SmartHome.isAutomationSupported() answers false everywhere.
An immutable snapshot.
Constructors
public Scene(String id, String name, String structureId, SceneType type, boolean executable, List<SceneAction> actions) | Creates a scene snapshot. |
Methods
public String getId() | The identifier this scene is addressed by. |
public String getName() | The user-visible name, empty when the scene has none. |
public String getStructureId() | The structure this scene belongs to. |
public SceneType getType() | What kind of scene this is. |
public boolean isExecutable() | Whether this scene can be run with SmartHome.executeScene(Scene). |
public List<SceneAction> getActions() | What this scene does. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Constructor details
Scene
public Scene(String id, String name, String structureId, SceneType type, boolean executable, List<SceneAction> actions)Parameters
idString- the scene identifier
nameString- the user-visible name, or
nullfor none structureIdString- the structure this scene belongs to
typeSceneType- what kind of scene it is;
nullbecomesSceneType.USER_DEFINED executableboolean- whether it can be run from here
actionsList<SceneAction>- what it does;
nullbecomes empty, which is also what a backend that will not enumerate a scene’s contents produces
Throws
IllegalArgumentException- when
idisnullor empty
Method details
getId
public String getId()Returns
nullgetName
public String getName()Returns
nullgetStructureId
public String getStructureId()Returns
null when unknowngetType
public SceneType getType()Returns
nullisExecutable
public boolean isExecutable()Whether this scene can be run with SmartHome.executeScene(Scene).
false for a SceneType.TRIGGER_OWNED scene, and for one the user’s
permissions on this home do not let them run. Calling
executeScene anyway fails with HomeError.UNAUTHORIZED rather than
quietly doing nothing, but checking first is how you avoid offering a
button that cannot work.
Returns
true when the scene can be rungetActions
public List<SceneAction> getActions()What this scene does.
Empty is not the same as “does nothing”. Some backends will run a scene without enumerating its contents, so an empty list means the platform did not say. Do not render “this scene is empty” from it.
Returns
toString
public String toString()