# Class Scene

java.lang.Object
com.codename1.home.Scene

public final class Scene extends Object

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
  Constructor
  Description
  `Scene(String id, String name, String structureId, SceneType type, boolean executable, List<SceneAction> actions)`
  Creates a scene snapshot.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<SceneAction>`
  `getActions()`
  What this scene does.
  `String`
  `getId()`
  The identifier this scene is addressed by.
  `String`
  `getName()`
  The user-visible name, empty when the scene has none.
  `String`
  `getStructureId()`
  The structure this scene belongs to.
  `SceneType`
  `getType()`
  What kind of scene this is.
  `boolean`
  `isExecutable()`
  Whether this scene can be run with `SmartHome.executeScene(Scene)`.
  `String`
  `toString()`
  Returns a string representation of the object.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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, or `null` for none

    - `structureId`: the structure this scene belongs to

    - `type`: what kind of scene it is; `null` becomes `SceneType.USER_DEFINED`

    - `executable`: whether it can be run from here

    - `actions`: what it does; `null` becomes empty, which is also what a backend that will not enumerate a scene's contents produces

    ###### Throws

    - `IllegalArgumentException`: when `id` is `null` or empty

- ## Method Details

  - ### getId

    public String getId()

    The identifier this scene is addressed by.

    ###### Returns

    the identifier, never `null`

  - ### getName

    public String 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

    public String getStructureId()

    The structure this scene belongs to.

    ###### Returns

    the structure identifier, or `null` when unknown

  - ### getType

    public SceneType 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)`.

    `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 run

  - ### getActions

    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

    an immutable list, possibly empty

  - ### toString

    public String toString()
    Description copied from class: `Object`
    Returns 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())
    Overrides:
      `toString` in class `Object`