Globals
Global variables store a single value that actions
can update at runtime with globals.set. globals is built into UbiHome.
globals: - id: door_open type: bool initial_value: falseAttributes
Section titled “Attributes”| Property | Description | Example |
|---|---|---|
id | Identifier used to reference the global. | door_open |
type | Value type: bool, int, float or string. | bool |
initial_value | Value the global starts with. Defaults per type. | false |
initial_value and globals.set accept the value as a plain YAML scalar
matching type (e.g. an unquoted false or 42) or as a quoted string
(e.g. 'false') — both are reconciled against the global’s declared type.
Globals are written via the globals.set action,
which takes id/value arguments instead of a single id:
- globals.set: id: door_open value: trueA bool global can also be read as the state of a
template switch using a globals.get lambda —
written in YAML, not code:
switch: - platform: template name: 'Relay' lambda: globals.get: door_openSimilar to ESPHome: Globals