No commit activity in last 3 years
No release in over 3 years
Project Simulator (in development) aims to make it easier to observe triggers and actions from an XML based model.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.1, >= 0.1.19
~> 0.2, >= 0.2.1
>= 0.2.0, ~> 0.2
 Project Readme

Using ProjectSimulator with the MAcroHub gem

require 'macrohub'
require 'projectsimulator'

s=<<EOF
macro: Morning welcoming announcement

trigger: Motion detected in the kitchen
action: Say 'Good morning'
action: webhook entered_kitchen
  url: http://someurl/?id=kitchen
constraint: between 7am and 7:30am

macro: Good night announcement
trigger: Motion detected in the kitchen
action: Say 'Good night'
constraint: After 10pm
EOF


mh = MacroHub.new(s)

ps = ProjectSimulator::Controller.new(mh)

$env = {time: Time.parse('7:15am')}
$debug = true
ps.trigger :motion, location: 'kitchen'
#=> ["say: Good morning", "webhook: http://someurl/?id=kitchen"] 

$env = {time: Time.parse('8:05pm')}
ps.trigger :motion, location: 'kitchen'
#=> []

$env = {time: Time.parse('10:05pm')}
ps.trigger :motion, location: 'kitchen'
#=> ["say: Good night"] 

In the above example a couple of macros are created in plain text. The 1st macro is triggered when there is motion detected in the kitchen between 7am and 7:30am. If successful it returns the message 'say: Good morning'.

The 2nd macro is triggered when there is motion detected in the kitchen after 10pm. If successful it returns the message 'say: Good night'.

The ProjectSimulator facilitates the execution of triggers, validation of constraints and invocation of actions in cooperation with the MacroHub gem.

Resources

macro macrohub gem simulator project projectsimulator macrodroid


Introducing the Project Simulator gem

require 'projectsimulator'

s = 'turn the kitchen light on
turn the livingroom gas_fire on
'
ps = ProjectSimulator::Model.new(s)
puts ps.xml
<building1>
  <kitchen>
    <light switch='on'/>
  </kitchen>
  <livingroom>
    <gas_fire switch='on'/>
  </livingroom>
</building1>
ps.request 'switch the livingroom gas_fire off'
puts ps.xml
<building1>
  <kitchen>
    <light switch='on'/>
  </kitchen>
  <livingroom>
    <gas_fire switch='off'/>
  </livingroom>
</building1>
ps.request 'switch the gas_fire on'
puts ps.xml
<building1>
  <kitchen>
    <light switch='on'/>
  </kitchen>
  <livingroom>
    <gas_fire switch='on'/>
  </livingroom>
</building1>
ps.request 'is the gas_fire on?'
#=> "The livingroom gas_fire is on."

Resources

home automation simulator gem projectsimulator project