 load('lib/statemachine.js')
 load('lib/timedevent.js')
 
+# File names to store state machine and events
 state_db_fn = 'heyu-run.db'
 event_db_fn = 'heyu-events.db'
 

    parse_opts(set,args2) if args2.length > 0
    set

# ---- Main program
args = clone(@arguments)  # don't need to do this, just for fun
set = parse_opts({},args)
appliances = read_json(state_db_fn)

if set?.id? and set.id
  if set.display_state
    print "# Display current state of",set.id

      appl2 = new HeyuAppliance(set.id, states: ['OFF', 'ON'])
      appl2.changeState(appl2.currentState(),set.event)
      appliances[appl2.name] = appl2

# ---- Write state machine to file
state_changed = false
for name,appl of appliances
  state_changed = true if appl.changed
