Official website

Wednesday, February 27, 2013

Web UI customization

Note: Latest version of Jubito use jquery mobile 1.4, the only difference to this guide is that there is a directory called themes under www and you have to paste your customized default.css and default.min.css files over there. [ Useful source: Creating a Custom Theme with ThemeRoller ]

To give your own flavor to the Jubito's web UI, a really easy task since it's developed with jQuery mobile.
Go to theme roller drag & drop colors of your choise to swatch A and click download. Unzip the downloaded file, go to themes folder and copy the .css file to Jubito's folder under www. Then rename it to default.css if it's not already.




 

That's it, enjoy the new look!

Tuesday, February 26, 2013

Instruction Set anatomy

An instruction set is a collection of actions that has 3 basic forms and cast as follows.

Launcher
Launchers allow modularity. A launcher is responsible to execute third party programs and making API calls against the framework. If any of the processes above has a returning output, then its associated to the final synthesis.
Third party programs are invoked with dot-slash (./) and API calls with the judo keyword.
 


IMPORTANT: Use with cause the dot-slash (./) method if you want to avoid deadlocks. It instructs the process component to wait indefinitely for the associated process to exit. In case of the example above with notepad, the process will completed when notepad will terminated. Purpose of this action is the expandability via custom scripts and programs that does a job, give an output and finally terminated.

Example in steps...

A simple shell script that returns 'john'


The launcher


The invoke method


Result of the launcher



Result of the method


In the above example we create a launcher of a program that returns a value in order to reproduce a new instruction set that also contains additional information. We can bypass this process if we just want to launch a program and not use its value for reproduction. Since everything is instruction sets, this can be achieved by a single task.


However run-calc cannot be called by another instruction set.

When you try to execute a program that takes arguments, you should use single or back quotes (' or `) to split the statement. It doesn't matter if the arguments contains double quotes (").
Syntax:
./'program.exe' '<arguments> "<arguments with quotes>"'
Example:
./'ffmpeg' '-t 00:00:20 -i "http://<cam ip>:<port>/videostream.asf?user=admin&pwd=xxx" "/home/%user%/Videos/IP-Cam/cam-%calendarday%-%calendarmonth%-%calendaryear%_%hour%-%minute%.asf"'

Event

Events are very convenient because you can make multiple calls with a single command. This could be a sequence of different instruction sets, functions or API calls delimited by semicolon and can be triggered by another instruction set container like this...

%~><event handler id>%
In this particular example %~>demohandler%


To view events, go to terminal tab and type...
judo event list

Final Synthesis
A command (demo) is a sentence consisted by plain text, function calls and/or launchers. A launcher must be invoked by asterisk (*) token which it represents a pointer to the launcher.


Tip: You can have a number of instruction sets with the same name. Thus will give us the ability to trigger a sequence of events with ascending order.
Update: Use events instead for a more convenient way.


If instead of the (dummy) notepad example we are triggering a program or a script that has a returning value, then the wildcard *test will be replaced by it and associated to the final output. For example, if we request a sensor value from the microcontroller then the result should be synthesized like...

The temperature is <value returned from *temp>. This is a demo. j.am.... has launched something that returns a value.

Check this post to see an example in action.

To view instruction sets, go to terminal tab and type...
judo inset list

Evaluation
Another feature we can include to expand functionality is the evaluation function. This allows us to evaluate one or more expressions and act accordingly.

In the next step, we create a simple notification when evaluation failed. Category and other fields are not essential since in this case we need just a notifier


Evaluate %day% function against string "Monday"


Test result


Indicators
Indicators used within an instruction set when we need to call a launcher or an event handler. Wildcards used by the framework are...

Asterisk (*) pointer to a launcher or just a reflection of another Instruction Set.

%value% represents an internal function call.

%~>value% represents an event handler.

Essential Resources

Built-in finctions and API

Wednesday, February 20, 2013

Evaluation

Evaluation of an expression within Instruction Set allows you to add logic and extend the functionality.

Function

  evalBool: Returns one of two states, depending on the evaluation of an expression.

Parameters

  Expression
     Required. Boolean. The expression you want to evaluate.
  True Part
     Required. Type: Instruction Set. Called when expression evaluates to True.
  False Part
     Required. Type: Instruction Set. Called when expression evaluates to False.

Syntax

  { evalBool(expression); <true part>; <false part>; }

Relational & Conditional Operators

 equal to: ==
                i.e. (x == y)
                i.e. ("x" == "y")
                * String comparison require quotes
 not equal to: !=
                i.e. (x != y)
                i.e. ("x" != "y")
                * String comparison require quotes
 greater than: >
                i.e. (x > y)
 less than: <
                i.e. (x < y)
 greater than or equal to: >=
                i.e. (x >= y)
 less than or equal to: <=
                i.e. (x <= y)

 conditional AND: &&

                i.e. (x > 10 && x < 20)
 conditional OR: ||
                i.e. (x == 10 || x == 20)

 contains (Supported on ver. 0.2.1 of libJanet. To check your version, go to terminal tab and type %about%)

                i.e. (this is a test ~> is a)
                i.e. (%todayconditions% ~> Sunny)

Example

  { evalBool(*getTemp > 30);  foo1; foo2; }

The above example can be translate like...

If temperature is greater than 30 degrees then turn on a fan (foo1) else turn it off (foo2)

foo1, foo2 represents Instruction Set names. You can have more than one or none at any part.

Arduino configuration

This summary is not available. Please click here to view the post.

Simple interface example with arduino

In this post we'll explain how to interface and access an arduino project over the internet or by LAN. In the following screenshot I'll display some actions that my arduino does.

For example, the sketch print MotionDetected to the serial port when PIR sensor detect motion, take illumination conditions on light command, read RF data from a remote control in order to transmit back to the corresponding device, and display the temperature when temp command is called.

Find out more on arduino tutorials

Let's make a simple paradigm with temp.


So, when temp command is sent to the serial monitor arduino returns the current temperature (1st screenshot). To create an interface, go to Control Panel/Instruction Sets/Add New Launcher. Enter a name (handler) and judo serial send <command> API call to transmit temp command to the serial port.


To make this action available to the dashboard, go to Control Panel/Instruction Sets/Add New Instruction Set and follow the screenshot.


We always put the asterisk (*) token before a launcher to invoke it and retrieve the return value. In this case temp should be described as *temp. Save the above example, go to the Dashboard, refresh the page and you'll see the new command we just create.


This is the result when it clicked. It will replace the *temp action with the value that arduino returns.


For further debugging, launchers and instruction sets can be tested via terminal tab.

 

In the same way we can make our security triggers, control appliances remotely, etc. More examples will follow.

Tuesday, February 19, 2013

Built-in functions and API

Please visit GitHub Wiki
From now on updates will take place on jaNET Framework GitHub Wiki.

Update applies to jaNET framework version 0.2.2+ 

Built-in functions and API commands are described below and it used for instruction set synthesis.
After you create a new InstructionSet you can debug it and see the response from terminal.



You can also debug a launcher (using judo API) before you make the call from Instruction Set. In demonstration below, I'm going to use the 'judo serial send' API to send 'temp' command to the serial port where arduino is connected. This action will automatically fetch the arduino response when it's available.




Once we have test the launcher we can proceed with a custom Instruction Set. Notice the asterisk (*) indicator in front that remarks the launcher.



See also Instruction Set anatomy.

Functions

    User and Greetings
  • %user% %whoami% - return user login
  • %daypart% %partofday% - return the current part of the day (morning, noon, evening, afternoon, night, midnight)
  • %salute% - return human greetings e.g.: good morning, good evening and good afternoon

    Check-in/Check-out
  • %usercheckin% %checkin% - change user status to true
  • %usercheckout% %checkout% - change user status to false
  • %whereami% - return the user status (absent/present)

    Weather (retrieve information from yahoo web service http://developer.yahoo.com/weather)
  • %todayday% - return current day
  • %todayconditions% - return current day conditions http://developer.yahoo.com/weather/#codes
  • %todaylow% - return current day low temperature
  • %todayhigh% - return current day high temperature
  • %tomorrowday% - return the day after
  • %tomorrowconditions% - return the day after conditions
  • %tomorrowlow% - return day after low temperature
  • %tomorrowhigh% - return day after high temperature

    Localization
  • %day% - return system day i.e. Sunday
  • %date% - return current system date i.e. November 5
  • %calendarday% - return system day i.e. 5
  • %calendarmonth% - return system month i.e. 11
  • %calendaryear% - return system year i.e. 2013
  • %calendardate% - return system date in d/m/yyyy format
  • %time% - return system time
  • %time24% - return system time in 24 format (hh:mm)
  • %hour% - return system hour i.e. 17
  • %minute% - return system minute

    Net
  • %pop3count% - pop3 unread message count
  • %gmailcount% - gmail unread message count
  • %gmailheaders% %gmailreader% %gheaders% %greader% - gmail headers, sender information and subject

    System
  • %mute% - disable speech synthesis
  • %unmute% - enable speech synthesis
  • %cls% %clear% - clearing the console
  • %quit% %exit% - terminate application
  • %about% %copyright% - return framework version and copyright information

API

(*) From the terminal tab you can type judo ? for the latest / updated help.

1. Instruction Sets & Events
    1.1 Add New Instruction Set
        + judo inset add <lock>[ID]</lock> <lock>[Action]</lock>
        + judo inset new
<lock>[ID]</lock> <lock>[Action]</lock>
        + judo inset set
<lock>[ID]</lock> <lock>[Action]</lock>
        + judo inset setup
<lock>[ID]</lock> <lock>[Action]</lock]
        + judo inset add
[ID] <lock>[Action]</lock> `[Category]` `[Header]` `[Short Description]` `[Long Description]` `[Thumbnail Url]`
        + judo inset new [ID] <lock>[Action]</lock> `[Category]` `[Header]` `[Short Description]` `[Long Description]` `[Thumbnail Url]`
        + judo inset set [ID] <lock>[Action]</lock> `[Category]` `[Header]` `[Short Description]` `[Long Description]` `
[Thumbnail Url]`
        +
judo inset setup [ID] <lock>[Action]</lock> `[Category]` `[Header]` `[Short Description]` `[Long Description]` `[Thumbnail Url]`
    1.2 Remove Instruction Set
        + judo inset remove <lock>[ID]</lock>
        + judo inset delete <lock>[ID]</lock>
        + judo inset del <lock>[ID]</lock>
        + judo inset kill <lock>[ID]</lock>

    1.3 List Items
        + judo inset list
    1.4 Add New Event Handler
        + judo event add [ID] <lock>[Action]</lock>
        + judo event new [ID] <lock>[Action]</lock>
        + judo event set [ID] <lock>[Action]</lock>
        + judo event setup [ID] <lock>[Action]</lock>

    1.5 Remove Event Handler
        + judo event remove [ID]
        + judo event delete [ID]
        + judo event del [ID]
        + judo event kill [ID]

    1.6 Delay Between Actions
        + judo sleep [timeout in ms]
        + judo timer [timeout in ms]

    1.7 List Items
        + judo event list

2. Mail
    2.1 Smtp Settings
        + judo smtp add [host] [username] [password] [port] [ssl]
        + judo smtp setup [host] [username] [password] [port] [ssl]
        + judo smtp set [host] [username] [password] [port] [ssl]
        + judo smtp settings

    2.2 Pop3 Settings
        + judo pop3 add [host] [username] [password] [port] [ssl]
        + judo pop3 setup [host] [username] [password] [port] [ssl]
        + judo pop3 set [host] [username] [password] [port] [ssl]
        + judo pop3 settings

    2.3 Gmail Settings
        + judo gmail add [username] [password]
        + judo gmail setup [username] [password]
        + judo gmail set [username] [password]
        + judo gmail settings

    2.4 Send
        + judo mail send [from address] [to address] `[subject]` `[message]`

3. SMS
    3.1 Settings
        + judo sms add [api id] [username] [password]
        + judo sms setup [api id] [username] [password]
        + judo sms set [api id] [username] [password]
        + judo sms setings

    3.2 Send
        + judo sms send [phone number] [message]

4. Scheduler
    4.1 New Schedule
        + judo schedule add [name] [{single day: e.g.Monday} {d/m/yyyy} {daily} {workdays} {weekend}] [hh:mm] [{instruction set} {verbal notification}]
        + judo schedule new [name] [{single day: e.g.Monday} {d/m/yyyy} {daily} {workdays} {weekend}] [hh:mm] [{instruction set} {verbal notification}]
        + judo schedule set [name] [{single day: e.g.Monday} {d/m/yyyy} {daily} {workdays} {weekend}] [hh:mm] [{instruction set} {verbal notification}]
        + judo schedule setup [name] [{single day: e.g.Monday} {d/m/yyyy} {daily} {workdays} {weekend}] [hh:mm] [{instruction set} {verbal notification}]
        + judo schedule add [name] [{repeat} {timer} {interval}] [interval in ms] [{instruction set} {verbal notification}]
        + judo schedule new [name] [{repeat} {timer} {interval}] [interval in ms] [instruction set} {verbal notification}]
        + judo schedule set [name] [{repeat} {timer} {interval}] [interval in ms] [instruction set} {verbal notification}]
        + judo schedule setup [name] [{repeat} {timer} {interval}] [interval in ms] [instruction set} {verbal notification}]

    4.2 Remove Schedule
        + judo schedule remove [name]
        + judo schedule delete [name]
        + judo schedule del [name]

    4.3 Disable Schedule
        + judo schedule disable [name]
        + judo schedule deactivate [name]
        + judo schedule stop [name]
        + judo schedule off [name]

    4.4 Enable Schedule
        + judo schedule enable [name]
        + judo schedule activate [name]
        + judo schedule start [name]
        + judo schedule on [name]

    4.5 Remove All Schedules
        + judo schedule remove-all
        + judo schedule delete-all
        + judo schedule del-all
        + judo schedule cleanup
        + judo schedule clear
        + judo schedule empty

    4.6 Disable All Schedules
        + judo schedule disable-all
        + judo schedule deactivate-all
        + judo schedule stop-all
        + judo schedule off-all

    4.7 Enable All Schedules
        + judo schedule enable-all
        + judo schedule activate-all
        + judo schedule start-all
        + judo schedule on-all

    4.8 List Actives [ Names ]
        + judo schedule active
        + judo schedule actives
        + judo schedule active-list
        + judo schedule active-ls
        + judo schedule list-actives
        + judo schedule ls-actives

    4.9 List Inactives [ Names ]
        + judo schedule inactive
        + judo schedule inactives
        + judo schedule inactive-list
        + judo schedule inactive-ls
        + judo schedule list-inactives
        + judo schedule ls-inactives

    4.10 List All [ Names ]
        + judo schedule names
        + judo schedule name-list
        + judo schedule name-ls
        + judo schedule list-names
        + judo schedule ls-names

    4.11 List Actives [ Details ]
        + judo schedule active-details
        + judo schedule actives-details
        + judo schedule active-list-details
        + judo schedule active-ls-details
        + judo schedule list-actives-details
        + judo schedule ls-actives-details

    4.12 List Inactives [ Details ]
        + judo schedule inactive-details
        + judo schedule inactives-details
        + judo schedule inactive-list-details
        + judo schedule inactive-ls-details
        + judo schedule list-inactives-details
        + judo schedule ls-inactives-details

    4.13 List All [ Details ]
        + judo schedule details [name (optional)]
        + judo schedule list [name (optional)]
        + judo schedule ls [name (optional)]
        + judo schedule status [name (optional)]
        + judo schedule state [name (optional)]


5. Socket Communication
    5.1 Start Service
        + judo socket start
        + judo socket enable
        + judo socket on
        + judo socket open
        + judo socket listen

    5.2 Stop Service
        + judo socket stop
        + judo socket disable
        + judo socket off
        + judo socket close

    5.3 Status
        + judo socket status
        + judo socket state


6. Web Server
    6.1 Start
        + judo server start
        + judo server enable
        + judo server on
        + judo server listen

    6.2 Stop
        + judo server stop
        + judo server disable
        + judo server off

    6.3 Create/Change Login
        + judo server login [username] [password]
        + judo server cred [username] [password]
        + judo server credentials [username] [password]

    6.4 Status
        + judo server status
        + judo server state


7. Serial Port
    7.1 Open
        + judo serial open [port (optional)]
    7.2 Close
        + judo serial close
    7.3 Send Command
        + judo serial send [command]
    7.4 Listen/Monitor
        + judo serial listen [timeout in ms (optional)]
        + judo serial monitor [timeout in ms (optional)]

8. Help
    8.1 Preview All
        + judo help
        + judo ?

    8.2 Preview Specific Category
        + judo help [help keyword]
        + judo ? [help keyword]


(*) Brackets are mandatory when place a sentence as one argument.
(**) <lock>parser protected document</lock> Lock tags used to bypass parser.
(***) Help Keywords: inset, event, mail, sms, schedule, socket, server, serial, help.

Sunday, February 17, 2013

Setup gmail, SMTP, POP3

Mail settings is really easy to setup. You can setup any owned account by easily go to Control Panel/Mail and under Setup hit the corresponding button.


These settings apply to %gmailcount%, %gmailreader%, %gmailheaders% and
%pop3count% functions which return information in order to synthesize a new Instruction Set that feed us with information. Responsible command for sending email is judo mail send [params]. A basic Wiki for judo API and built-in functions.

NEW: System email alerts use predefined headers and can be configured by the UI.




If you own a domain name that is associated with your gmail, you can use it as well by giving the full address, e.g. me@mydomain.com.

SMTP is used for sending email notifications when user status is away (system: absent). You can use gmail SMTP for that action. It will also use the headers mentioned above. For example when you receive an email from the system, it will be in form:
Mail from: noreply@xxx.org
Mail to: you@yyy.org
Subject: Alert from Jubito
Body: Any action happened.


Host: smtp.gmail.com
Username: <your_account_name>
Password: <your password>
Port: 587
SSL: True

Setup Clickatel SMS gateway

Clickatel is a famous SMS gateway and its natively supported by Jubito system for sending SMS notifications.

If you already have an account then you can simply go to Control Panel/SMS/Setup and set the API, username and password you've been provided by Clickatel service.

To send an SMS within an Instruction Set do the follow.
Go to Instruction Sets menu and add a new launcher. In the popup window type...

Name: <yourdesiredname> e.g. smsssender
Action: judo sms send <number> `<your message here>`

Telephone format should include the country code, e.g.: +301234567890


When you save the launcher, then it's ready to be invoked by other Instruction Set (see example below) or by using the smssender command. Notice that you need to put an asterisk (*) before launcher in order to be invoked.


If you want to represent this action to dashboard, then fill Category and Header fields. Short description and description are optional.

It can also be revoked by the emergency call button in the main screen.