Skip to content

Instantly share code, notes, and snippets.

@sdebruyn
Last active July 23, 2025 19:52
Show Gist options
  • Save sdebruyn/402cc93915a82cbee6bb4a5f9a6f9ce5 to your computer and use it in GitHub Desktop.
Save sdebruyn/402cc93915a82cbee6bb4a5f9a6f9ce5 to your computer and use it in GitHub Desktop.
HomeFlow schema
{
"$defs": {
"Aspect": {
"description": "An aspect is a data point we're listening to for changes that can be used in a condition in a HomeFlow context.",
"properties": {
"address": {
"description": "Address of the aspect in dotted notation. This can be a 2-part or a 3-part address.",
"examples": [
"sensor.temperature",
"light.living_room.brightness"
],
"pattern": "^[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(\\.[A-Za-z0-9_]+)?$",
"title": "Address",
"type": "string"
},
"alias": {
"anyOf": [
{
"pattern": "^[a-zA-Z0-9_]+$",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Alias for the aspect, if any",
"title": "Alias"
},
"typ": {
"default": "float",
"description": "Type of the aspect, can be 'float' (default), 'int', 'str' or 'bool'.",
"examples": [
"float",
"int",
"str",
"bool"
],
"pattern": "^(float|int|str|bool)$",
"title": "Typ",
"type": "string"
}
},
"required": [
"address"
],
"title": "Aspect",
"type": "object"
},
"Condition": {
"description": "A condition is an expression that can be evaluated to determine if a Context is active or not.",
"title": "Condition",
"type": "string"
},
"Context": {
"description": "A context is a set of conditions that must all be true for the context to be active.",
"properties": {
"name": {
"description": "Name of the context, used to reference it in HomeFlows.",
"title": "Name",
"type": "string"
},
"conditions": {
"description": "Conditions which must all be true for the context to be active.",
"items": {
"$ref": "#/$defs/Condition"
},
"title": "Conditions",
"type": "array",
"uniqueItems": true
}
},
"required": [
"name",
"conditions"
],
"title": "Context",
"type": "object"
},
"State": {
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "A state represents a target state for the target in a HomeFlow.\nWhen one of the contexts become active, the target will be set to this state.\nThe state can have multiple attribute values, which are the attributes that will be set on the target.",
"properties": {
"when": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "string"
}
],
"description": "Contexts in which this state is active, can be a single context or a list of contexts.\nLeave empty (or don't specify) for the default state.",
"title": "When"
}
},
"title": "State",
"type": "object"
}
},
"properties": {
"target": {
"description": "Target address for the flow in dotted notation.",
"examples": [
"cover.living_room_curtain.position",
"input_value.value"
],
"pattern": "^[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(\\.[A-Za-z0-9_]+)?$",
"title": "Target",
"type": "string"
},
"shared_contexts": {
"anyOf": [
{
"additionalProperties": {
"items": {
"$ref": "#/$defs/Condition"
},
"type": "array",
"uniqueItems": true
},
"type": "object"
},
{
"items": {
"$ref": "#/$defs/Context"
},
"type": "array"
}
],
"description": "Contexts which can then be reused from other HomeFlows.\nTheir names have to be unique across all HomeFlows.\nOnly include contexts which are used in this HomeFlow.",
"title": "Shared Contexts"
},
"aspects": {
"anyOf": [
{
"additionalProperties": {
"anyOf": [
{
"examples": [
"sensor.temperature",
"light.living_room.brightness"
],
"pattern": "^[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(\\.[A-Za-z0-9_]+)?$",
"type": "string"
},
{
"$ref": "#/$defs/Aspect"
}
]
},
"type": "object"
},
{
"items": {
"$ref": "#/$defs/Aspect"
},
"type": "array"
}
],
"description": "Aspects which are used in this HomeFlow.\nAn aspect is a data point we're listening to for changes that can be used in a condition in a HomeFlow context.\nAspects are globally unique across all HomeFlows. No need to define them in more than one flow.",
"title": "Aspects"
},
"contexts": {
"anyOf": [
{
"additionalProperties": {
"items": {
"$ref": "#/$defs/Condition"
},
"type": "array",
"uniqueItems": true
},
"type": "object"
},
{
"items": {
"$ref": "#/$defs/Context"
},
"type": "array"
}
],
"description": "Contexts which are only used in this HomeFlow.\nA context is a set of conditions which should all be true for the context to be active.",
"title": "Contexts"
},
"states": {
"description": "States which the flow can be in.\nEach state can have a set of contexts. The state becomes active when any of the contexts is active.\nOne state can have no contexts, which means it is the default state.\nStates are evaluated in the order they are defined.",
"items": {
"$ref": "#/$defs/State"
},
"minItems": 2,
"title": "States",
"type": "array"
}
},
"required": [
"target",
"states"
],
"title": "HomeFlow",
"type": "object"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment