Class 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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionWhat this scene does.getId()The identifier this scene is addressed by.getName()The user-visible name, empty when the scene has none.The structure this scene belongs to.getType()What kind of scene this is.booleanWhether this scene can be run withSmartHome.executeScene(Scene).toString()Returns a string representation of the object.
-
Constructor Details
-
Scene
public Scene(String id, String name, String structureId, SceneType type, boolean executable, List<SceneAction> actions) Creates a scene snapshot. Called by the ports and by the local home.
Parameters
-
id: the scene identifier -
name: the user-visible name, ornullfor none -
structureId: the structure this scene belongs to -
type: what kind of scene it is;nullbecomesSceneType.USER_DEFINED -
executable: whether it can be run from here -
actions: what it does;nullbecomes empty, which is also what a backend that will not enumerate a scene's contents produces
Throws
IllegalArgumentException: whenidisnullor empty
-
-
-
Method Details
-
getId
The identifier this scene is addressed by.
Returns
the identifier, never
null -
getName
The user-visible name, empty when the scene has none. The user's own text; treat it as untrusted beyond display.
Returns
the name, never
null -
getStructureId
The structure this scene belongs to.
Returns
the structure identifier, or
nullwhen unknown -
getType
What kind of scene this is.
Returns
the type, never
null -
isExecutable
public boolean isExecutable()Whether this scene can be run with
SmartHome.executeScene(Scene).falsefor aSceneType.TRIGGER_OWNEDscene, and for one the user's permissions on this home do not let them run. CallingexecuteSceneanyway fails withHomeError.UNAUTHORIZEDrather than quietly doing nothing, but checking first is how you avoid offering a button that cannot work.Returns
truewhen the scene can be run -
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
an immutable list, possibly empty
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-