Skip to content

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: false
PropertyDescriptionExample
idIdentifier used to reference the global.door_open
typeValue type: bool, int, float or string.bool
initial_valueValue 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: true

A 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_open

Similar to ESPHome: Globals