Project

macrohub

0.0
No commit activity in last 3 years
No release in over 3 years
Experimental gem to create macros with the aim to simulate home automation.
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.4.0, ~> 0.4
>= 0.7.0, ~> 0.7
>= 1.0.0, ~> 1.0
 Project Readme

Introducing 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