Blockly

From ago control wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "= Create events using blocks= == Introduction == First of all you need to know how agocontrol is working: * When a device change its status, an event is triggered into agocon...")
 
Line 73: Line 73:
  
  
== Blocks definitions ==
+
== Examples ==
 +
 
 +
Examples of what can be done with Blockly can be found below, if you have questions relating to the examples please post on the [http://www.agocontrol.com/forum/index.php?topic=383.0]
 +
 
 +
=== Example 1 ===
 +
Every Monday 01.37 send an email, with temperature + distance measurement to an email address
 +
 
 +
[[File:Blockly TempDistance2Email.png]]
 +
 
 +
=== Example 2 ===
 +
If today is an odd number day of the month, at 7pm turn on a switch for an hour then switches it off and turns another one on for another hour.
 +
 
 +
[[File:Blockly Irrigation.png]]

Revision as of 23:01, 15 February 2015

Contents

Create events using blocks

Introduction

First of all you need to know how agocontrol is working:

  • When a device change its status, an event is triggered into agocontrol.
  • This event is propagated among all agocontrol modules and catched by event handler.
  • An event is containing some related informations. All this informations are called "event content"

With an example:

I have a temperature sensor and when this device detects a temperature changing, the event "temperature has changed" is triggered. Agocontrol system catch this event and execute all actions associated to this event. The event "temperature has changed" is containing the sensor unique id (uuid) and the new temperature value.

Now you know how agocontrol is working so you should be able to create an action.


Getting started

Agocontrol proposes an easy way to create these actions without any computer skills (or a little bit) using blocks construction. Dashboard is composed of:

  • an area on top with buttons
  • a menu on the left
  • a construction area

Top area

Top area is composed of buttons:

  • Save button: save your action. First saving request you an action name.
  • Load button: open a popup that list all existing actions. This popup allows you to delete useless actions.
  • Check button: click on it if you want to check if there are some mistakes on your action
  • Show button: open a popup to show you generated script from your blocks.
  • Clear button: reset construction area.

Menu

Root sections

The menu of the left is divided on sections:

  • "Logic" section contains logic block like if and comparison
  • "Loops" section allows you to iterate on something
  • "Math" section adds some mathematical operations
  • "Colour" adds color picker
  • "Text" section contains all you need to manipulate strings
  • "List" section allows you to manipulate array
  • "Datetime" gives you access to date and time functions
  • "Common" appends common functions (like print something on screen)
  • "Variables" allows you to declare local variables to save informations of your action
  • "Procedures" contains blocks to add functions in your action
  • "Agocontrol" is a specific section that contains agocontrol inventory, devices, values... This section is explained above

Agocontrol section

Agocontrol section contains specific blocks that will allow you to interact with the home automation system:

  • "Content" section
    • "triggered event" block catches current event content (remember, content contains the event triggered, its values...)
    • "content prop" block gives you access to current content properties (ie current temperature...)
  • "Inventory" section
    • "device value" block returns value of specified agocontrol device
  • "Device" section gives access to device uuids or names
  • "Event" section gives acces to event names
  • "Actions" section
    • "Send command" allows you to control agocontrol sending commands like send mail or sms, open or close your shutters...
    • "Sleep" pauses your script during amount of specified command
  • "Variables" section gives access to agocontrol internal variables. Very useful to keep in mind some information.

Construction area

By default, on construction you should see default blocks:

  • a logic "if" block that creates a condition
  • a content "triggered event" block that catches an event
  • an "event" block that specifies the event you want to catch

How to

Building an action is really simple: drag and drop blocks from left menu to construction area and plug them together. Blocks inputs and outputs have type checking to drive you. Some blocks have little blue stars on top left corner, clicking on this star open a popup to add some features to the block.


Examples

Examples of what can be done with Blockly can be found below, if you have questions relating to the examples please post on the [1]

Example 1

Every Monday 01.37 send an email, with temperature + distance measurement to an email address

Blockly TempDistance2Email.png

Example 2

If today is an odd number day of the month, at 7pm turn on a switch for an hour then switches it off and turns another one on for another hour.

Blockly Irrigation.png

Personal tools