# Updatable


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

<br />

Known direct subclasses [ActivatedCarbonFilterMonitoring](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ActivatedCarbonFilterMonitoring), [AreaAttendanceState](https://developers.home.google.com/reference/kotlin/com/google/home/google/AreaAttendanceState), [AreaPresenceState](https://developers.home.google.com/reference/kotlin/com/google/home/google/AreaPresenceState), [Automation](https://developers.home.google.com/reference/kotlin/com/google/home/automation/Automation), [BasicInformation](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/BasicInformation), [Binding](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Binding), [BooleanStateConfiguration](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/BooleanStateConfiguration), [ChimeThemes](https://developers.home.google.com/reference/kotlin/com/google/home/google/ChimeThemes), [Chime](https://developers.home.google.com/reference/kotlin/com/google/home/google/Chime), [Chime](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Chime), [ColorControl](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ColorControl), [ConfigurationDone](https://developers.home.google.com/reference/kotlin/com/google/home/google/ConfigurationDone), [Connectivity](https://developers.home.google.com/reference/kotlin/com/google/home/google/Connectivity), [DoorLock](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/DoorLock), [EnergyEvse](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/EnergyEvse), [EnergyPreference](https://developers.home.google.com/reference/kotlin/com/google/home/google/EnergyPreference), [EnergyPreference](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/EnergyPreference), [ExtendedDoorLock](https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedDoorLock), [ExtendedFanControl](https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedFanControl), [ExtendedGeneralDiagnostics](https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedGeneralDiagnostics), [ExtendedLevelControl](https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedLevelControl), [ExtendedThermostat](https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedThermostat), [FaceLibrary](https://developers.home.google.com/reference/kotlin/com/google/home/google/FaceLibrary), [FanControl](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/FanControl), [GroupMembership](https://developers.home.google.com/reference/kotlin/com/google/home/google/GroupMembership), [Group](https://developers.home.google.com/reference/kotlin/com/google/home/google/Group), [HepaFilterMonitoring](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/HepaFilterMonitoring), [HubManagement](https://developers.home.google.com/reference/kotlin/com/google/home/google/HubManagement), [Identify](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Identify), [LaundryDryerControls](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LaundryDryerControls), [LaundryWasherControls](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LaundryWasherControls), [LevelControl](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LevelControl), [LightingCurve](https://developers.home.google.com/reference/kotlin/com/google/home/google/LightingCurve), [LocalizationConfiguration](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LocalizationConfiguration), [ModeSelect](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ModeSelect), [Mount](https://developers.home.google.com/reference/kotlin/com/google/home/google/Mount), [OccupancySensing](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/OccupancySensing), [OnOff](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/OnOff), [OtaSoftwareUpdateRequestor](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/OtaSoftwareUpdateRequestor), [PowerTopology](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/PowerTopology), [PumpConfigurationAndControl](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/PumpConfigurationAndControl), [RecordingMode](https://developers.home.google.com/reference/kotlin/com/google/home/google/RecordingMode), [StructureUserManagement](https://developers.home.google.com/reference/kotlin/com/google/home/google/StructureUserManagement), [ThermostatFanControl](https://developers.home.google.com/reference/kotlin/com/google/home/google/ThermostatFanControl), [ThermostatUserInterfaceConfiguration](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ThermostatUserInterfaceConfiguration), [Thermostat](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Thermostat), [ThreadNetworkSettings](https://developers.home.google.com/reference/kotlin/com/google/home/google/ThreadNetworkSettings), [UnitTesting](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/UnitTesting), [UserLabel](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/UserLabel), [UserPresenceSettings](https://developers.home.google.com/reference/kotlin/com/google/home/google/UserPresenceSettings), [ValveConfigurationAndControl](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ValveConfigurationAndControl), [VisitorAnnouncement](https://developers.home.google.com/reference/kotlin/com/google/home/google/VisitorAnnouncement), [VoiceStarter](https://developers.home.google.com/reference/kotlin/com/google/home/google/VoiceStarter), [Weather](https://developers.home.google.com/reference/kotlin/com/google/home/google/Weather), [WindowCovering](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/WindowCovering), [ZoneManagement](https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ZoneManagement)

|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ActivatedCarbonFilterMonitoring` | API for the ActivatedCarbonFilterMonitoring trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/AreaAttendanceState` | This trait provides an interface for the current attendance state of known household members in a Structure. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/AreaPresenceState` | This trait provides an interface for the current area presence state for a given Structure, for example, home or away, occupied or unoccupied. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Automation` | The main representation an automation, composed of various types of Automation nodes, including `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Starter` instances, `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Condition` instances, `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Action` instances, and more. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/BasicInformation` | API for the BasicInformation trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Binding` | API for the Binding trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/BooleanStateConfiguration` | API for the BooleanStateConfiguration trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ChimeThemes` | API for the ChimeThemes trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/Chime` | API for the Chime trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Chime` | API for the Chime trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ColorControl` | API for the ColorControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ConfigurationDone` | API for the ConfigurationDone trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/Connectivity` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/DoorLock` | API for the DoorLock trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/EnergyEvse` | API for the EnergyEvse trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/EnergyPreference` | API for the EnergyPreference trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/EnergyPreference` | API for the EnergyPreference trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedDoorLock` | API for the ExtendedDoorLock trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedFanControl` | API for the ExtendedFanControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedGeneralDiagnostics` | API for the ExtendedGeneralDiagnostics trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedLevelControl` | API for the ExtendedLevelControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ExtendedThermostat` | API for the ExtendedThermostat trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/FaceLibrary` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/FanControl` | API for the FanControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/GroupMembership` | API for the GroupMembership trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/Group` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/HepaFilterMonitoring` | API for the HepaFilterMonitoring trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/HubManagement` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Identify` | API for the Identify trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LaundryDryerControls` | API for the LaundryDryerControls trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LaundryWasherControls` | API for the LaundryWasherControls trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LevelControl` | API for the LevelControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/LightingCurve` | Structure level trait for managing lighting curves. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/LocalizationConfiguration` | API for the LocalizationConfiguration trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ModeSelect` | API for the ModeSelect trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/Mount` | API for the Mount trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/OccupancySensing` | API for the OccupancySensing trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/OnOff` | API for the OnOff trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/OtaSoftwareUpdateRequestor` | API for the OtaSoftwareUpdateRequestor trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/PowerTopology` | API for the PowerTopology trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/PumpConfigurationAndControl` | API for the PumpConfigurationAndControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/RecordingMode` | API for the RecordingMode trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/StructureUserManagement` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ThermostatFanControl` | API for the ThermostatFanControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ThermostatUserInterfaceConfiguration` | API for the ThermostatUserInterfaceConfiguration trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/Thermostat` | API for the Thermostat trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/ThreadNetworkSettings` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/UnitTesting` | API for the UnitTesting trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/UserLabel` | API for the UserLabel trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/UserPresenceSettings` |   |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ValveConfigurationAndControl` | API for the ValveConfigurationAndControl trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/VisitorAnnouncement` | API for the VisitorAnnouncement trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/VoiceStarter` | API for the VoiceStarter trait, which is available on a structure entity only. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/google/Weather` | This trait provides an interface for the weather conditions for a given Structure. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/WindowCovering` | API for the WindowCovering trait. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/matter/standard/ZoneManagement` | API for the ZoneManagement trait. |

Known indirect subclasses [MutableAutomation](https://developers.home.google.com/reference/kotlin/com/google/home/automation/MutableAutomation)

|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/MutableAutomation` | Mutable attributes for an `Automation`. |

*** ** * ** ***

This interface keeps the lifecycle of mutable objects within the scope of the `https://developers.home.google.com/reference/kotlin/com/google/home/Updatable#update(kotlin.Function1,kotlin.Function1)` function.

## Summary

| ### Public functions |
|---|---|
| `suspend IMMUTABLE` | `https://developers.home.google.com/reference/kotlin/com/google/home/Updatable#update(kotlin.Function1,kotlin.Function1)(optimisticReturn: (IMMUTABLE) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html, init: MUTABLE.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` 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:

```kotlin
device.getTrait(OnOff).update { this.onTime = OptionalValue.present(10u) }
```

| Parameters |
|---|---|
| `optimisticReturn: (IMMUTABLE) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html = {}` | the function that is passed a version of the Trait that has the optimistic mutations blended with its current state. |
| `init: MUTABLE.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | the function which mutates the object. |