# StateRegister

A StateRegister is used when you want to **permanently (persistently) maintain a certain state value within a domain**.

- State values are stored permanently.
- If set for automatic publish, any change in value will automatically trigger a publish (event emission).
- Subscribers will automatically receive the current value at the moment they start subscribing.

This feature is mainly used in [scenarios](../concept/scenario.md) with the following patterns:

- Used to persist any value within a domain.
- You can utilize state values in scenarios by writing to or reading from the state register (state-write, state-read).
- When publishing a value to a client, if there is a state-register with the same name as the publish tag, it will be automatically updated.

---

[State-register(state-register)](../concept/state-register.md) is a screen that defines values for states with specific meanings.

- This function is usually used by tasks in [scenario](../concept/scenario.md) such as [state-write](../task/state-write.md), [state-read](../task/state-read.md).

## Properties

- Name (name)
  - Specifies the name of the state
  - Name must be unique
- Description (description)
- Type (type)
  - Arbitrary text can be entered, and it is for the purpose of users differentiating among the states
- TTL (Time To Live)
  - The valid time of the state value can be defined in seconds.
  - If the TTL value is greater than 0, it is considered set.
  - The last set state value becomes invalid after the TTL time has passed
- State Value (state)
  - Refers to the current value of this state.
- Last Modified (wrote at)
  - The last time the state value was modified

## Operations

- Save (save state-register)
  - Saves changes in the state register.
- Delete (delete state-register)
  - Deletes the selected state register.
