Updatable

interface Updatable<IMMUTABLE : Any?, MUTABLE : Any?>

Known direct subclasses
ActivatedCarbonFilterMonitoring

API for the ActivatedCarbonFilterMonitoring trait.

AreaAttendanceState
AreaPresenceState
Automation

The main representation an automation, composed of various types of Automation nodes, including Starter instances, Condition instances, Action instances, and more.

BasicInformation

API for the BasicInformation trait.

Binding

API for the Binding trait.

BooleanStateConfiguration

API for the BooleanStateConfiguration trait.

CameraAvStreamManagement

API for the CameraAvStreamManagement trait.

ChimeThemes

API for the ChimeThemes trait.

Chime

API for the Chime trait.

ColorControl

API for the ColorControl trait.

ConfigurationDone

API for the ConfigurationDone trait.

DoorLock

API for the DoorLock trait.

EnergyEvse

API for the EnergyEvse trait.

ExtendedDoorLock

API for the ExtendedDoorLock trait.

ExtendedFanControl

API for the ExtendedFanControl trait.

ExtendedThermostat

API for the ExtendedThermostat trait.

FanControl

API for the FanControl trait.

HepaFilterMonitoring

API for the HepaFilterMonitoring trait.

HubManagement
Identify

API for the Identify trait.

LaundryDryerControls

API for the LaundryDryerControls trait.

LaundryWasherControls

API for the LaundryWasherControls trait.

LevelControl

API for the LevelControl trait.

ModeSelect

API for the ModeSelect trait.

OccupancySensing

API for the OccupancySensing trait.

OnOff

API for the OnOff trait.

OtaSoftwareUpdateRequestor

API for the OtaSoftwareUpdateRequestor trait.

PumpConfigurationAndControl

API for the PumpConfigurationAndControl trait.

ThermostatUserInterfaceConfiguration

API for the ThermostatUserInterfaceConfiguration trait.

Thermostat

API for the Thermostat trait.

UnitTesting

API for the UnitTesting trait.

UserLabel

API for the UserLabel trait.

ValveConfigurationAndControl

API for the ValveConfigurationAndControl trait.

VoiceStarter
Weather
WindowCovering

API for the WindowCovering trait.

Known indirect subclasses
MutableAutomation

Mutable attributes for an Automation.


This interface keeps the lifecycle of mutable objects within the scope of the update function.

Summary

Public functions

suspend IMMUTABLE
update(optimisticReturn: (IMMUTABLE) -> Unit, init: MUTABLE.() -> Unit)

Creates a mutable copy of an object and calls the given function to mutate it, then saves it and returns a new immutable copy with the updated state.

Public functions

update

suspend fun update(optimisticReturn: (IMMUTABLE) -> Unit = {}, init: MUTABLE.() -> Unit): IMMUTABLE

Creates a mutable copy of an object and calls the given function to mutate it, then saves it and returns a new immutable copy with the updated state.

For example:

device.getTrait(OnOff).update { this.onTime = OptionalValue.present(10u) }
Parameters
optimisticReturn: (IMMUTABLE) -> Unit = {}

the function that is passed a version of the Trait that has the optimistic mutations blended with its current state.

init: MUTABLE.() -> Unit

the function which mutates the object.