The Homylon language is a small domain-specific language for describing how a home should behave. It is not intended to be Python, Java or a general-purpose programming language. Its vocabulary is focused on homes: things, rooms, sensors, lamps, sounds, times, events and habits.
Scenes and packages
Rules live in plain-text scene files with a suffix .scene. A package is in fact simply a folder whose name ends inĀ .homylon; so a collection of scene files in a standard folder also works. When a package is opened, the Engine reads definitions and rules, then waits for the events that should make them act. The files belong to the owner: they can be edited, copied, backed up and read without a special application.
Four families of sentences
- Definitions describe the house: homes, agents, devices, rooms, groups, remotes and monitors.
- Actions make something happen: switch a lamp, play a sound, open a curtain, send a message or run a scene.
- Structures decide when or whether actions happen:
when,if,else,afterandloop. - Variables give the house memory, for example
holiday = 1orguests = 2.
sub warmwhite by FFD8A0
define room livingroom lights sofalamp, readinglamp
when time sunset then
light livingroom on warmwhite brightness 40 fade 3
end
Readable syntax
Homylon is case-insensitive. Names start with a letter and may contain letters, digits and hyphens; quoted names can contain spaces. Keywords cannot be used as names. Values include numbers, six-digit hexadecimal colours, times such as 07:30, and text beginning with @, such as @"Someone is at the front door".
Each line is a sentence. Three dots continue a long sentence on the next line. # and // start comments, while /* ... */, /# ... #/ and ## ... ## can comment out a block. Blocks use then ... end, do ... end, begin ... end or curly braces. A one-line form is available when a rule has one obvious action.
The language allows natural alternatives: or and ||, and and &&, after and delay, and loop and while. Small connective words such as seconds, at, in and on may often be left out. Use the longer form when it makes the rule easier to read later.
Describe first, behave second
A good scene normally defines the home, agents, devices, groups and substitutions near the top, then places variables and behaviour below. Agents can announce devices automatically; written definitions are used for quiet agents, groups, monitors and human-friendly names, and your written definitions win when they conflict with an announcement.
holiday = false
when motion on frontdoorsensor and variable holiday = false then
light hallwayceiling, studylamp on
else
send notification @"Someone is at the front door" to emma
end
Rules are descriptions of behaviour, not a list of commands that runs once. A when rule waits for its trigger; an if decides immediately; after waits without blocking the rest of the Engine; loop repeats; and variables let one part of the house communicate its state to another.
Based on the Homylon User Manual - Draft, chapters 2 through 7 and appendix C.