A compact reference for writing Homylon scenes. Homylon is case-insensitive and reads one sentence per line.
Core shape
# comment
sub warmwhite by FFD8A0
define home myhouse latitude 52.09 longitude 5.12
when <trigger> [and <condition>] then
<action>
end
Names and values
- Names start with a letter and may contain letters, digits and hyphens:
frontdoorsensor,lamp2,hall-ceiling. - Use double quotes for spaces:
"sofa lamp". - Numbers:
40,0.5. Colours:FFD8A0. Times:07:30. - Yes/no values:
yes,on,true,1,closedand their opposites (no,off,false,0,open). - Literal text starts with
@:@"Welcome home".
Definitions
define agent gardenpi address 192.168.1.60 port 55300 protocol udp
define light fountainlight on hub gardenpi
define sensor gardenthermometer type temperature on gardenpi
define room livingroom lights sofalamp, readinglamp
define group outsidelights lights porchlight, fountainlight
define remote emmasphone
monitor all on emmaipad address 192.168.1.30 port 55213 protocol udp
home, agent, room, group, floor and monitor may omit define. The words agent, hub and broker are equivalent; so are room, group and floor.
Actions
light porchlight on
light livingroom on warmwhite brightness 40 fade 3
light halllamp off
sound dingdong on soundmachine
open curtain livingcurtains 70
close door frontdoor
play music playlist on livingspeakers
send notification @"Someone is at the door" to mark
log @"Rule fired"
scene evening
Triggers and structures
when time sunset then scene evening
when motion on frontdoorsensor then light porchlight on
when time sunset - 30 then light livingroom on warmwhite 40
when motion on hallmotion and time between 23:00 and 07:00 then
light bedroomlamp on warmwhite 10 fade 2
end
if holiday then
send notification @"The house is in holiday mode" to emma
else
scene normal
end
after 30
light porchlight off
end
loop 5 times after 2
light hallwaylamp on
end
Use or or a comma for alternatives; use and or && for combined conditions. Square brackets group complex conditions. A one-line rule needs no end: when time sunset then scene evening.
A when time fires at one moment: when time 07:00, when time sunset, when time sunrise + 30. A time window belongs in a condition, after and or in an if: and time between 23:00 and 07:00, if time between sunset and sunrise. A window can also be written between 23:00 07:00, 23:00 <> 07:00 or > 23:00 and < 07:00; > 23:00 alone means after 23:00, < 07:00 before 07:00. Sun times can be moved by minutes: sunset - 30, sunrise + 15.
not turns any condition around, in an if and after and: if not holiday, and not time between 23:00 and 07:00, and not saturday, sunday. A when cannot start with not, because it waits for something to happen: write when holiday = no.
Variables and substitutions
holiday = no
guests = 2
message = @"Guests: " + guests
nightlevel = 40 / 4
when holiday then scene away
when holiday = no then scene normal
if not holiday then light porchlight on
when guests > 0 then light livingroom on
sub red by FF0000
sub sofa by "sofa lamp"
Punctuation and style
... continues a long sentence. # and // start comments. Commas make lists. then ... end or { ... } make blocks. Parentheses calculate values or hold extra name/value details, such as (pattern: stars, speed: slow). A dot names a part, such as emmasphone.movienight.
Define first, keep scenes small, indent blocks, and comment the reason for a rule. Those habits make a plain-text home understandable years later.