浏览代码

Merge pull request #38 from kalliope-project/dev

Dev
Nicolas Marcq 8 年之前
父节点
当前提交
0b604bcead

+ 30 - 31
Docs/brain.md

@@ -19,11 +19,11 @@ Let's take a look on a basic synapse in our brain:
 ```
 ```
 ---
 ---
   - name: "Say-hello"
   - name: "Say-hello"
-    neurons:      
-      - say:
-          message: "Hello, sir"
     signals:
     signals:
       - order: "say hello"
       - order: "say hello"
+    neurons:      
+      - say:
+          message: "Hello, sir"    
 ```
 ```
 
 
 Let's break this down in sections so we can understand how the file is built and what each part means.
 Let's break this down in sections so we can understand how the file is built and what each part means.
@@ -41,29 +41,8 @@ At the top level we have a "name" tag. This is the **unique identifier** of the
 - name: "Say-hello"
 - name: "Say-hello"
 ```
 ```
 
 
-Then we have the neurons declaration. Neurons are modules that will be executed when the input action is triggered. You can define as many neurons as you want to the same input action (for example: say somethning, then do something etc...). This declaration contains a list (because it starts with a "-") of neurons
-```
-neurons:
-    - neuron_1_name
-    - neuron_2_name
-    - another_neuron
-```
-
-The order of execution of neurons is defined by the order in which they are listed in neurons declaration.
-
-Some neurons need parameters that can be passed as arguments following the syntax bellow:
-```
-neurons:
-    - neuron_name:
-        parameter1: "value1"
-        parameter2: "value2"
-```
-Note here that parameters are indented with one tabulation bellow the neuron's name (YAML syntax requirement).
-
-In this example, the neuron called "say" will make Kalliope speak out loud the sentence in parameter **message**.
-See the complete list of [available neurons](neurons.md) here.
 
 
-The last part, called **signals** is a list of input actions. This works exactly the same way as neurons. You must place here at least one action.
+The first part, called **signals** is a list of input actions. This works exactly the same way as neurons. You must place here at least one action.
 In the following example, we use just one signal, an order. See the complete list of [available signals](signals.md) here.
 In the following example, we use just one signal, an order. See the complete list of [available signals](signals.md) here.
 ```
 ```
 signals:
 signals:
@@ -85,19 +64,39 @@ To know if your order will be triggered by Kalliope, we recommend you to [use th
 You must pay attention to define the orders as precise as possible. As Kalliope is based on matching, if you define your orders in different synapses too similiary, Kalliope risks to trigger more actions that you were expecting. For exemple, if you define two different synapses as shown below:
 You must pay attention to define the orders as precise as possible. As Kalliope is based on matching, if you define your orders in different synapses too similiary, Kalliope risks to trigger more actions that you were expecting. For exemple, if you define two different synapses as shown below:
 ```
 ```
 - name: "Say-hello"
 - name: "Say-hello"
-...
-signals:
-  - order: "say hello"
+  signals:
+    - order: "say hello"
 ```
 ```
 and 
 and 
 ```
 ```
 - name: "Say-something"
 - name: "Say-something"
-...
-signals:
-  - order: "say"
+  signals:
+    - order: "say"
 ```
 ```
 When you will pronounce "say hello", it will trigger both synapses. 
 When you will pronounce "say hello", it will trigger both synapses. 
 
 
+Then we have the neurons declaration. Neurons are modules that will be executed when the input action is triggered. You can define as many neurons as you want to the same input action (for example: say somethning, then do something etc...). This declaration contains a list (because it starts with a "-") of neurons
+```
+neurons:
+    - neuron_1_name
+    - neuron_2_name
+    - another_neuron
+```
+
+The order of execution of neurons is defined by the order in which they are listed in neurons declaration.
+
+Some neurons need parameters that can be passed as arguments following the syntax bellow:
+```
+neurons:
+    - neuron_name:
+        parameter1: "value1"
+        parameter2: "value2"
+```
+Note here that parameters are indented with one tabulation bellow the neuron's name (YAML syntax requirement).
+
+In this example, the neuron called "say" will make Kalliope speak out loud the sentence in parameter **message**.
+See the complete list of [available neurons](neurons.md) here.
+
 ## Manage synapses
 ## Manage synapses
 
 
 Kalliope provides also a REST API to manage your synapses (get the list, get one, run one), refer to [rest api documentation](rest_api.md) for more details.
 Kalliope provides also a REST API to manage your synapses (get the list, get one, run one), refer to [rest api documentation](rest_api.md) for more details.

+ 8 - 7
Docs/neuron_template.md

@@ -31,13 +31,14 @@ Only necessary when the neuron use a template to say something
 Description of what the synapse will do
 Description of what the synapse will do
 ```
 ```
  - name: "type here your name"
  - name: "type here your name"
-    neurons:      
-      - neuron_name:
-          parameter: "value"
-          parameter: "value"
-          file_template: template_name.j2
-    signals:
-      - order: "this is what I have to say to run this synapse"
+   signals:
+     - order: "this is what I have to say to run this synapse"
+   neurons:      
+     - neuron_name:
+        parameter: "value"
+        parameter: "value"
+        file_template: template_name.j2
+    
 ```
 ```
 
 
 ## Templates example 
 ## Templates example 

+ 6 - 7
Docs/neurons.md

@@ -42,14 +42,14 @@ neurons:
 From the captured order:
 From the captured order:
 ```
 ```
   - name: "run-neuron-with-parameter-in-order"
   - name: "run-neuron-with-parameter-in-order"
+    signals:
+      - order: "this is an order with the parameter {{ parameter3 }}"
     neurons:
     neurons:
       - neuron_name:
       - neuron_name:
           parameter1: "value1"
           parameter1: "value1"
           parameter2: "value2"
           parameter2: "value2"
           args:
           args:
           - parameter3
           - parameter3
-    signals:
-      - order: "this is an order with the parameter {{ parameter3 }}"
 ```
 ```
 
 
 Here, the spoken value captured by the TTS engine will be passed as an argument to the neuron in the variable named `parameter3`.
 Here, the spoken value captured by the TTS engine will be passed as an argument to the neuron in the variable named `parameter3`.
@@ -76,12 +76,12 @@ It is {{ hours }} and {{ minutes }} minutes.
 Placed in a complete synapse, it looks like the following
 Placed in a complete synapse, it looks like the following
 ```
 ```
 - name: "time"
 - name: "time"
+    signals:
+      - order: "what time is it"
     neurons:
     neurons:
       - systemdate:
       - systemdate:
           say_template:
           say_template:
             - "It is {{ hours }} hours and {{ minutes }} minutes"
             - "It is {{ hours }} hours and {{ minutes }} minutes"
-    signals:
-      - order: "what time is it"
 ```
 ```
 
 
 Here, we use [variables](http://jinja.pocoo.org/docs/dev/templates/#variables) from the neuron into our template file. Both variables will be interpreted by the template engine. 
 Here, we use [variables](http://jinja.pocoo.org/docs/dev/templates/#variables) from the neuron into our template file. Both variables will be interpreted by the template engine. 
@@ -99,15 +99,14 @@ We can add some logic to a template with tags. Here a simple example with [a tes
 As this is multi-lines, we can put the content in a file and use a `file_template` instead of a `say_template` for more clarity.
 As this is multi-lines, we can put the content in a file and use a `file_template` instead of a `say_template` for more clarity.
 ```
 ```
 - name: "time"
 - name: "time"
+    signals:
+      - order: "what time is it"
     neurons:
     neurons:
       - systemdate:
       - systemdate:
           file_template: /path/to/file/template.j2
           file_template: /path/to/file/template.j2
-    signals:
-      - order: "what time is it"
 ```
 ```
 
 
 
 
-
 ## Overridable parameters
 ## Overridable parameters
 
 
 For each neuron, you can override some parameters to use a specific configuration of TTS instead of the default one 
 For each neuron, you can override some parameters to use a specific configuration of TTS instead of the default one 

+ 2 - 2
Docs/signals.md

@@ -72,6 +72,8 @@ Let's make a complete example. We want Kalliope to wake us up each morning of wo
 The synapse in the brain would be
 The synapse in the brain would be
 ```
 ```
   - name: "wake-up"
   - name: "wake-up"
+    signals:
+      - event: "0 7 * * 1,2,3,4,5"
     neurons:
     neurons:
       - say:
       - say:
           message:
           message:
@@ -80,8 +82,6 @@ The synapse in the brain would be
           say_template:
           say_template:
             - "It is {{ hours }} hours and {{ minutes }} minutes"
             - "It is {{ hours }} hours and {{ minutes }} minutes"
       - command: "mplayer http://192.99.17.12:6410/"
       - command: "mplayer http://192.99.17.12:6410/"
-    signals:
-      - event: "0 7 * * 1,2,3,4,5"
 ```
 ```
 
 
 After setting up an event, you must restart Kalliope
 After setting up an event, you must restart Kalliope

+ 4 - 5
README.md

@@ -10,15 +10,14 @@ Kalliope can run on all Linux distribution including a Raspberry Pi and it's mul
 
 
 Kalliope is easy-peasy to use, see the hello world
 Kalliope is easy-peasy to use, see the hello world
 ```
 ```
-  - name: "Hello world"
-    neurons:      
-      - say:
-          message: "Hello world!"
+  - name: "Hello-world"
     signals:
     signals:
       - order: "say hello"
       - order: "say hello"
+    neurons:      
+      - say:
+          message: "Hello world!"    
 ```
 ```
 
 
-
 ## Installation
 ## Installation
 
 
 - [Automated installation](Docs/automated_install.md)
 - [Automated installation](Docs/automated_install.md)

+ 3 - 3
brain_examples/fr/fr_clock_radio.yml

@@ -1,5 +1,7 @@
 ---
 ---
-  - name: "wake up"
+  - name: "wake-up"
+    signals:
+        - event: "30 7 * * 1,2,3,4,5" # each morning of working day at 7:30
     neurons:
     neurons:
       - say:
       - say:
           message:
           message:
@@ -8,5 +10,3 @@
           say_template:
           say_template:
             - "Il est {{ hours }} heures et {{ minutes }} minutes"
             - "Il est {{ hours }} heures et {{ minutes }} minutes"
       - command: "mplayer http://192.99.17.12:6410/"  # Launch Asterisk radio
       - command: "mplayer http://192.99.17.12:6410/"  # Launch Asterisk radio
-    signals:
-      - event: "30 7 * * 1,2,3,4,5" # each morning of working day at 7:30

+ 6 - 7
brain_examples/fr/fr_systemdate.yml

@@ -1,17 +1,16 @@
-- name: "Say local date"
+- name: "say-local-date"
+  signals:
+    - order: "test"
   neurons:
   neurons:
     - systemdate:
     - systemdate:
         say_template:
         say_template:
           - "Il est {{ hours }} heures et {{ minutes }} minutes"
           - "Il est {{ hours }} heures et {{ minutes }} minutes"
         tts: "voxygen"
         tts: "voxygen"
-  signals:
-    - order: "test"
 
 
-
-- name: "Say local date"
+- name: "say-local-date2"
+  signals:
+    - order: "tempate"
   neurons:
   neurons:
     - systemdate:
     - systemdate:
         file_template: fr_systemdate_template_example.j2
         file_template: fr_systemdate_template_example.j2
         tts: "voxygen"
         tts: "voxygen"
-  signals:
-    - order: "tempate"

+ 3 - 3
brain_examples/fr/hello_world.yml

@@ -1,9 +1,9 @@
 ---
 ---
-  - name: "Say hello"
+  - name: "say-hello"
+    signals:
+      - order: "dit bonjour"
     neurons:
     neurons:
       - say:
       - say:
           message:
           message:
             - "Bonjour monsieur"
             - "Bonjour monsieur"
             - "Bonjour maitre"
             - "Bonjour maitre"
-    signals:
-      - order: "dit bonjour"

+ 4 - 4
brain_examples/fr/say_examples.yml

@@ -1,8 +1,8 @@
 ---
 ---
-  - name: "Meaning of life"
+  - name: "meaning-of-life"
+    signals:
+      - order: "quel est le sens de la vie"
     neurons:
     neurons:
       - say:
       - say:
           message:
           message:
-            - "42"
-    signals:
-      - order: "test"
+            - "42"

+ 3 - 4
brains/ansible_playbook.yml

@@ -1,9 +1,8 @@
 ---
 ---
-
-  - name: "Ansible-test"
+  - name: "snsible-test"
+    signals:
+      - order: "playbook"
     neurons:
     neurons:
       - ansible_playbook: "tasks.yml"
       - ansible_playbook: "tasks.yml"
       - say:
       - say:
           message: "Tache terminée"
           message: "Tache terminée"
-    signals:
-      - order: "playbook"

+ 2 - 2
brains/gmail_checker.yml

@@ -1,10 +1,10 @@
 ---
 ---
 
 
   - name: "check-email"
   - name: "check-email"
+    signals:
+      - order: "est-ce que j'ai des emails"
     neurons:
     neurons:
       - gmail_checker:
       - gmail_checker:
           username: "me@gmail.com"
           username: "me@gmail.com"
           password: "my_password"
           password: "my_password"
           file_template: fr_gmail.j2
           file_template: fr_gmail.j2
-    signals:
-      - order: "est-ce que j'ai des emails"

+ 2 - 2
brains/kill_switch.yml

@@ -1,9 +1,9 @@
 ---
 ---
 
 
   - name: "stop-kalliope"
   - name: "stop-kalliope"
+    signals:
+      - order: "ferme-toi"
     neurons:
     neurons:
       - say:
       - say:
           message: "Aurevoir"
           message: "Aurevoir"
       - kill_switch
       - kill_switch
-    signals:
-      - order: "ferme-toi"

+ 9 - 10
brains/neurotransmitter.yml

@@ -1,5 +1,7 @@
 ---
 ---
   - name: "synapse1"
   - name: "synapse1"
+    signals:
+      - order: "pose moi une question"
     neurons:
     neurons:
       - say:
       - say:
           message: "aimez vous les frites?"
           message: "aimez vous les frites?"
@@ -13,28 +15,25 @@
               answers:
               answers:
                 - "non"
                 - "non"
           default: "synapse4"
           default: "synapse4"
-    signals:
-      - order: "pose moi une question"
 
 
   - name: "synapse2"
   - name: "synapse2"
+    signals:
+      - order: "synapse2"
     neurons:
     neurons:
       - say:
       - say:
           message: "Vous aimez les frites! Moi aussi!"
           message: "Vous aimez les frites! Moi aussi!"
-    signals:
-      - order: "synapse2"
+
 
 
   - name: "synapse3"
   - name: "synapse3"
+    signals:
+      - order: "synapse3"
     neurons:
     neurons:
       - say:
       - say:
           message: "vous n'aimez pas les frites. c'est pas grave."
           message: "vous n'aimez pas les frites. c'est pas grave."
-    signals:
-      - order: "synapse3"
 
 
   - name: "synapse4"
   - name: "synapse4"
+    signals:
+      - order: "synapse4"
     neurons:
     neurons:
       - say:
       - say:
           message: "Je n'ai pas compris votre réponse"
           message: "Je n'ai pas compris votre réponse"
-    signals:
-      - order: "synapse4"
-
-

+ 2 - 2
brains/openweathermap.yml

@@ -1,5 +1,7 @@
 ---
 ---
   - name: "get-the-weather"
   - name: "get-the-weather"
+    signals:
+      - order: "quel temps fait-il"
     neurons:
     neurons:
       - openweathermap:
       - openweathermap:
           api_key: "your-api"
           api_key: "your-api"
@@ -9,5 +11,3 @@
           country: "FR"
           country: "FR"
           say_template:
           say_template:
           - "Aujourd'hui a {{ location }} le temps est {{ weather_today }} avec une température de {{ temp_today_temp }} degrés et demain le temps sera {{ weather_tomorrow }} avec une température de {{ temp_tomorrow_temp }} degrés"
           - "Aujourd'hui a {{ location }} le temps est {{ weather_today }} avec une température de {{ temp_today_temp }} degrés et demain le temps sera {{ weather_tomorrow }} avec une température de {{ temp_tomorrow_temp }} degrés"
-    signals:
-      - order: "quel temps fait-il "

+ 2 - 2
brains/push_message.yml

@@ -1,9 +1,9 @@
 ---
 ---
   - name: "send-push-message"
   - name: "send-push-message"
+    signals:
+      - order: "push message"
     neurons:
     neurons:
       - push_message:
       - push_message:
            message: "Message to send"
            message: "Message to send"
            api_key: "my_token_key"
            api_key: "my_token_key"
            channel_name: "my_chanel_name"
            channel_name: "my_chanel_name"
-    signals:
-      - order: "push message"

+ 3 - 3
brains/say.yml

@@ -1,9 +1,9 @@
 ---
 ---
   - name: "Say-hello"
   - name: "Say-hello"
+    signals:
+      - order: "bonjour"
+      - order: "Bonjour"
     neurons:
     neurons:
       - say:
       - say:
           message:
           message:
             - "Bonjour monsieur"
             - "Bonjour monsieur"
-    signals:
-      - order: "bonjour"
-      - order: "Bonjour"

+ 2 - 2
brains/script.yml

@@ -1,9 +1,9 @@
 ---
 ---
   - name: "run-simple-script"
   - name: "run-simple-script"
+    signals:
+      - order: "lance le script"
     neurons:
     neurons:
       - script:
       - script:
           path: "/var/tmp/coucou.sh"
           path: "/var/tmp/coucou.sh"
       - say:
       - say:
           message: "Script lancé, monsieur"
           message: "Script lancé, monsieur"
-    signals:
-      - order: "lance le script"

+ 17 - 16
brains/shell.yml

@@ -1,25 +1,26 @@
 ---
 ---
 
 
   - name: "close-rolling-shutter"
   - name: "close-rolling-shutter"
+    signals:
+      - order: "ferme les volets"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl http://192.168.0.22:5000/fermeture -d \"password=monpass\" -X POST"
           cmd: "curl http://192.168.0.22:5000/fermeture -d \"password=monpass\" -X POST"
       - say:
       - say:
           message: "Fermeture en cours, monsieur"
           message: "Fermeture en cours, monsieur"
-    signals:
-      - order: "ferme les volets"
 
 
   - name: "open-rolling-shutter"
   - name: "open-rolling-shutter"
+    signals:
+      - order: "ouvre les volets"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl http://192.168.0.22:5000/ouverture -d \"password=monpass\" -X POST"
           cmd: "curl http://192.168.0.22:5000/ouverture -d \"password=monpass\" -X POST"
       - say:
       - say:
           message: "Ouverture en cours, monsieur"
           message: "Ouverture en cours, monsieur"
-    signals:
-      - order: "ouvre les volets"
-
 
 
   - name: "start-steam"
   - name: "start-steam"
+    signals:
+      - order: "lance Steam"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
@@ -27,10 +28,11 @@
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
       - say:
       - say:
           message: "Lancement en cours, monsieur"
           message: "Lancement en cours, monsieur"
-    signals:
-      - order: "lance Steam"
+
 
 
   - name: "start-Kodi"
   - name: "start-Kodi"
+    signals:
+      - order: "lance Cody"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
@@ -38,26 +40,25 @@
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
       - say:
       - say:
           message: "Lancement en cours, monsieur"
           message: "Lancement en cours, monsieur"
-    signals:
-      - order: "lance Cody"
+
 
 
   - name: "start-music"
   - name: "start-music"
+    signals:
+      - order: "mais nous de la musique"
+      - order: "musique rock"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
       - say:
       - say:
           message: "Musique lance, monsieur"
           message: "Musique lance, monsieur"
-    signals:
-      - order: "mais nous de la musique"
-      - order: "musique rock"
 
 
   - name: "stop-music"
   - name: "stop-music"
+    signals:
+      - order: "arrête la musique"
+      - order: "stop la musique"
+      - order: "éteins la musique"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
       - say:
       - say:
           message: "musique stoppé, monsieur"
           message: "musique stoppé, monsieur"
-    signals:
-      - order: "arrête la musique"
-      - order: "stop la musique"
-      - order: "éteins la musique"

+ 4 - 4
brains/systemdate.yml

@@ -1,17 +1,17 @@
 ---
 ---
 
 
   - name: "say-local-date"
   - name: "say-local-date"
+    signals:
+      - order: "quelle heure est-il"
     neurons:
     neurons:
       - systemdate:
       - systemdate:
           tts: "voxygen"
           tts: "voxygen"
           say_template:
           say_template:
             - "il est {{ hours }} heure et {{ minutes }} minute"
             - "il est {{ hours }} heure et {{ minutes }} minute"
-    signals:
-      - order: "quelle heure est-il"
 
 
   - name: "say-local-date-from-template"
   - name: "say-local-date-from-template"
+    signals:
+      - order: "test heure"
     neurons:
     neurons:
       - systemdate:
       - systemdate:
           file_template: en_systemdate_template_example.j2
           file_template: en_systemdate_template_example.j2
-    signals:
-      - order: "test heure"

+ 2 - 2
brains/tasker_autoremote.yml

@@ -1,11 +1,11 @@
 ---
 ---
 
 
   - name: "find-my-phone"
   - name: "find-my-phone"
+    signals:
+      - order: "où est mon téléphone"
     neurons:
     neurons:
       - say:
       - say:
           message: "Je fais sonner le téléphone, monsieur"
           message: "Je fais sonner le téléphone, monsieur"
       - tasker_autoremote:
       - tasker_autoremote:
           key: "APA91bqmY"
           key: "APA91bqmY"
           message: "lost"
           message: "lost"
-    signals:
-      - order: "où est mon téléphone"

+ 2 - 2
brains/twitter.yml

@@ -1,6 +1,8 @@
 ---
 ---
 
 
   - name: "post-tweet"
   - name: "post-tweet"
+    signals:
+      - order: "envoie sur Twitter {{ tweet }}"
     neurons:
     neurons:
       - twitter:
       - twitter:
           consumer_key: ""
           consumer_key: ""
@@ -11,5 +13,3 @@
           - "voici le tweet {{ tweet }}"
           - "voici le tweet {{ tweet }}"
           args:
           args:
             - tweet
             - tweet
-    signals:
-      - order: "envoie sur Twitter {{ tweet }}"

+ 3 - 2
brains/wake_on_lan.yml

@@ -1,8 +1,9 @@
 ---
 ---
 
 
   - name: "wake-my-PC"
   - name: "wake-my-PC"
+    signals:
+      - order: "wake my PC"
     neurons:
     neurons:
       - wake_on_lan:
       - wake_on_lan:
           mac_address: "00-00-00-00-00-00"
           mac_address: "00-00-00-00-00-00"
-    signals:
-      - order: "wake my PC"
+

+ 2 - 2
brains/wikipedia.yml

@@ -1,11 +1,11 @@
 ---
 ---
 
 
   - name: "wikipedia-search"
   - name: "wikipedia-search"
+    signals:
+      - order: "cherche sur Wikipédia {{ query }}"
     neurons:
     neurons:
       - wikipedia:
       - wikipedia:
           language: "fr"
           language: "fr"
           args:
           args:
             - query
             - query
           file_template: "wikipedia_returned_value.j2"
           file_template: "wikipedia_returned_value.j2"
-    signals:
-      - order: "cherche sur Wikipédia {{ query }}"

+ 9 - 1
core/NeuronModule.py

@@ -157,7 +157,15 @@ class NeuronModule(object):
             sys.setdefaultencoding('utf-8')
             sys.setdefaultencoding('utf-8')
             # the user choose a file_template option
             # the user choose a file_template option
             if self.file_template is not None:  # the user choose a file_template option
             if self.file_template is not None:  # the user choose a file_template option
-                real_file_template_path = "templates/%s" % self.file_template
+                if not os.path.isabs(self.file_template):  # os.path.isabs returns True if the path is absolute
+                    # here we are
+                    dir_we_are = os.path.dirname(os.path.realpath(__file__))
+                    # root directory
+                    root_dir = os.path.normpath(dir_we_are + os.sep + os.pardir)
+                    # real path of the template
+                    real_file_template_path = os.path.join(root_dir, self.file_template)
+                else:
+                    real_file_template_path = self.file_template
                 if os.path.isfile(real_file_template_path):
                 if os.path.isfile(real_file_template_path):
                     # load the content of the file as template
                     # load the content of the file as template
                     t = Template(self._get_content_of_file(real_file_template_path))
                     t = Template(self._get_content_of_file(real_file_template_path))

+ 6 - 6
neurons/ansible_playbook/README.md

@@ -21,13 +21,13 @@ This neuron can be used to perform complex operation with all [modules available
 
 
 Call the playbook named playbook.yml
 Call the playbook named playbook.yml
 ```
 ```
-   - name: "Ansible-test"
+  - name: "Ansible-test"
+    signals:
+      - order: "playbook"
     neurons:
     neurons:
       - ansible_playbook: "playbook.yml"
       - ansible_playbook: "playbook.yml"
       - say:
       - say:
-          message: "Tache terminée"
-    signals:
-      - order: "playbook"
+          message: "Tache terminée"    
 ```
 ```
 
 
 Content of the playbook. This playbook will use the [URI module](http://docs.ansible.com/ansible/uri_module.html) to interact with a webservice on a remote server.
 Content of the playbook. This playbook will use the [URI module](http://docs.ansible.com/ansible/uri_module.html) to interact with a webservice on a remote server.
@@ -67,9 +67,9 @@ Shell neuron or script neuron can perform same actions. Ansible is just a way to
 Here is the example of synapse you would use to perform a call to a web service without Ansible:
 Here is the example of synapse you would use to perform a call to a web service without Ansible:
 ```
 ```
 - name: "start-music"
 - name: "start-music"
+    signals:
+      - order: "start music rock"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:8000/app"      
           cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:8000/app"      
-    signals:
-      - order: "start music rock"
 ```
 ```

+ 6 - 6
neurons/gmail_checker/README.md

@@ -24,26 +24,26 @@ Simple example :
 
 
 ```
 ```
   - name: "check-email"
   - name: "check-email"
+    signals:
+      - order: "Do I have emails"
     neurons:
     neurons:
       - gmail_checker:
       - gmail_checker:
           username: "me@gmail.com"
           username: "me@gmail.com"
           password: "my_password"
           password: "my_password"
           say_template: 
           say_template: 
-            -  "You have {{ unread }} new emails"
-    signals:
-      - order: "Do I have emails"
+            -  "You have {{ unread }} new emails"    
 ```
 ```
 
 
 A complex example that read subject emails. This is based on a file_template
 A complex example that read subject emails. This is based on a file_template
 ```
 ```
   - name: "check-email"
   - name: "check-email"
+    signals:
+      - order: "Do I have emails"
     neurons:
     neurons:
       - gmail_checker:
       - gmail_checker:
           username: "me@gmail.com"
           username: "me@gmail.com"
           password: "my_password"
           password: "my_password"
-          file_template: /templates/my_email_template.j2            
-    signals:
-      - order: "Do I have emails"
+          file_template: /templates/my_email_template.j2
 ```
 ```
 
 
 Here the content of the `my_email_template.j2`
 Here the content of the `my_email_template.j2`

+ 2 - 2
neurons/kill_switch/README.md

@@ -18,10 +18,10 @@ Simple example :
 
 
 ```
 ```
   - name: "stop-kalliope"
   - name: "stop-kalliope"
-    neurons:
-      - kill_switch
     signals:
     signals:
       - order: "goodbye"
       - order: "goodbye"
+    neurons:
+      - kill_switch    
 ```
 ```
 
 
 
 

+ 8 - 8
neurons/neurotransmitter/README.md

@@ -25,6 +25,8 @@ If the user say something that is not present in `answers`, he will be redirecte
 
 
 ```
 ```
  - name: "synapse1"
  - name: "synapse1"
+    signals:
+      - order: "ask me a question"
     neurons:
     neurons:
       - say:
       - say:
           message: "do you like french fries?"
           message: "do you like french fries?"
@@ -38,29 +40,27 @@ If the user say something that is not present in `answers`, he will be redirecte
               answers:
               answers:
                 - "no at all"
                 - "no at all"
           default: "synapse4"
           default: "synapse4"
-    signals:
-      - order: "ask me a question"
 
 
   - name: "synapse2"
   - name: "synapse2"
+    signals:
+      - order: "synapse2"
     neurons:
     neurons:
       - say:
       - say:
           message: "You like french fries!! Me too! I suppose..."
           message: "You like french fries!! Me too! I suppose..."
-    signals:
-      - order: "synapse2"
 
 
   - name: "synapse3"
   - name: "synapse3"
+    signals:
+      - order: "synapse3"
     neurons:
     neurons:
       - say:
       - say:
           message: "You don't like french fries. It's ok."
           message: "You don't like french fries. It's ok."
-    signals:
-      - order: "synapse3"
       
       
   - name: "synapse4"
   - name: "synapse4"
+    signals:
+      - order: "synapse4"
     neurons:
     neurons:
       - say:
       - say:
           message: "I havn't understood your answer"
           message: "I havn't understood your answer"
-    signals:
-      - order: "synapse4"
 ```
 ```
 
 
 
 

+ 7 - 10
neurons/openweathermap/README.md

@@ -51,7 +51,9 @@ Give the today and tomorrow weather with the related data (humidity, temperature
 ## Synapses example
 ## Synapses example
 
 
 ```
 ```
-  - name: "get the weather"
+  - name: "getthe-weather"
+    signals:
+      - order: "what is the weather in {{ location }}"
     neurons:
     neurons:
       - openweathermap:
       - openweathermap:
           api_key: "fdfba4097c318aed7836b2a85a6a05ef"
           api_key: "fdfba4097c318aed7836b2a85a6a05ef"
@@ -61,15 +63,13 @@ Give the today and tomorrow weather with the related data (humidity, temperature
           - "Today in {{ location }} the weather is {{ weather_today }} with a temperature of {{ temp_today_temp }} degree and tomorrow the weather will be {{ weather_tomorrow }} with a temperature of {{ temp_tomorrow_temp }} degree"
           - "Today in {{ location }} the weather is {{ weather_today }} with a temperature of {{ temp_today_temp }} degree and tomorrow the weather will be {{ weather_tomorrow }} with a temperature of {{ temp_tomorrow_temp }} degree"
           args:
           args:
           - location
           - location
-    signals:
-      - order: "what is the weather in {{ location }}"
-
 ```
 ```
 
 
 You also can define the "location" args directly in neuron argument list. 
 You also can define the "location" args directly in neuron argument list. 
-
 ```
 ```
-  - name: "get the weather"
+  - name: "get-the-weather"
+    signals:
+      - order: "quel temps fait-il"
     neurons:
     neurons:
       - openweathermap:
       - openweathermap:
           api_key: "fdfba4097c318aed7836b2a85a6a05ef"
           api_key: "fdfba4097c318aed7836b2a85a6a05ef"
@@ -79,15 +79,12 @@ You also can define the "location" args directly in neuron argument list.
           country: "FR"
           country: "FR"
           say_template:
           say_template:
           - "Aujourd'hui a {{ location }} le temps est {{ weather_today }} avec une température de {{ temp_today_temp }} degrés et demain le temps sera {{ weather_tomorrow }} avec une température de {{ temp_tomorrow_temp }} degrés"
           - "Aujourd'hui a {{ location }} le temps est {{ weather_today }} avec une température de {{ temp_today_temp }} degrés et demain le temps sera {{ weather_tomorrow }} avec une température de {{ temp_tomorrow_temp }} degrés"
-    signals:
-      - order: "quel temps fait-il "
 ```
 ```
 
 
 ## Templates example 
 ## Templates example 
 
 
-
 ```
 ```
-    Today in {{ location }} the weather is {{ weather_today }} with a temperature of {{ temp_today_temp }} degree
+Today in {{ location }} the weather is {{ weather_today }} with a temperature of {{ temp_today_temp }} degree
 ```
 ```
 
 
 
 

+ 7 - 7
neurons/push_message/Readme.md

@@ -32,14 +32,14 @@ No returned value
 
 
 The following synapse will send a push message to device that have subscribed to the channel name "my_chanel_name" when you say "push message".
 The following synapse will send a push message to device that have subscribed to the channel name "my_chanel_name" when you say "push message".
 ```
 ```
- - name: "Send push message"
-    neurons:
-      - android_pushetta:
-           message: "Message to send"
-           api_key: "TOEKENEXAMPLE1234"
-           channel_name: "my_chanel_name"
-    signals:
+ - name: "send-push-message"
+   signals:
       - order: "push message"
       - order: "push message"
+   neurons:
+     - android_pushetta:
+         message: "Message to send"
+         api_key: "TOEKENEXAMPLE1234"
+         channel_name: "my_chanel_name"    
 ```
 ```
 
 
 ## Notes
 ## Notes

+ 16 - 16
neurons/say/README.md

@@ -19,27 +19,27 @@ No returned values
 Simple example : 
 Simple example : 
 
 
 ```
 ```
-   - name: "Say-hello"
-    neurons:
-      - say:
-          message:
-            - "Hello Sir"
-    signals:
-      - order: "hello"
+- name: "Say-hello"
+  signals:
+    - order: "hello"
+  neurons:
+    - say:
+        message:
+          - "Hello Sir"     
 ```
 ```
 
 
 With a multiple choice list, Kalliope will pick one randomly:
 With a multiple choice list, Kalliope will pick one randomly:
 
 
 ```
 ```
-   - name: "Say-hello"
-    neurons:
-      - say:
-          message:
-            - "Hello Sir"
-            - "Welcome Sir"
-            - "Good morning Sir"
-    signals:
-      - order: "hello"
+- name: "Say-hello"
+  signals:
+    - order: "hello"
+  neurons:
+    - say:
+        message:
+          - "Hello Sir"
+          - "Welcome Sir"
+          - "Good morning Sir"
 ```
 ```
 
 
 
 

+ 3 - 3
neurons/script/README.md

@@ -20,11 +20,11 @@ Simple example :
 
 
 ```
 ```
   - name: "run-simple-script"
   - name: "run-simple-script"
-    neurons:
-      - script:
-          path: "/path/to/script.sh"
     signals:
     signals:
       - order: "Run the script"
       - order: "Run the script"
+    neurons:
+      - script:
+          path: "/path/to/script.sh"    
 ```
 ```
 
 
 
 

+ 17 - 17
neurons/shell/README.md

@@ -27,66 +27,66 @@ Values are only returned by the neuron if the async mode is set to `False`.
 
 
 Simple that will create a file locally
 Simple that will create a file locally
 ```
 ```
-  - name: "create a local file"
-    neurons:
-      - shell:
-          cmd: "touch ~/test.txt"
+  - name: "create-a-local-file"
     signals:
     signals:
       - order: "touch"
       - order: "touch"
+    neurons:
+      - shell:
+          cmd: "touch ~/test.txt"    
 ```
 ```
 
 
 We want to launch our favorite web radio. This command, which it call mplayer, will block the entire Kalliope process if we 
 We want to launch our favorite web radio. This command, which it call mplayer, will block the entire Kalliope process if we 
 wait for the result unless the mplayer process is killed. So we add async parameter. 
 wait for the result unless the mplayer process is killed. So we add async parameter. 
 ``` 
 ``` 
-  - name: "run web radio"
+  - name: "run-web-radio"
+    signals:
+      - order: "run web radio"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "mplayer http://192.99.17.12:6410/"
           cmd: "mplayer http://192.99.17.12:6410/"
           async: True
           async: True
       - say:
       - say:
           message: "web radio lanched"
           message: "web radio lanched"
-    signals:
-      - order: "run web radio"
 ```
 ```
 If the parameter `async` is set to True, the neuron will not return any values.
 If the parameter `async` is set to True, the neuron will not return any values.
 
 
 
 
 Then, we can kill the player process with another synapse
 Then, we can kill the player process with another synapse
 ```
 ```
-  - name: "stop web radio"
+  - name: "stop-web-radio"
+    signals:
+      - order: "stop web radio"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "pkill mplayer"
           cmd: "pkill mplayer"
       - say:
       - say:
           message: "web radio stopped"
           message: "web radio stopped"
-    signals:
-      - order: "stop web radio"
 ```
 ```
 
 
 Make Kalliope add two number and speak out loud the result. Here you should hear "4".
 Make Kalliope add two number and speak out loud the result. Here you should hear "4".
 ```
 ```
-  - name: "get the result of the addition: 1 + 3"
+  - name: "get-the-result-of-the-addition"
+    signals:
+      - order: "addition"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "echo $(expr \"1\" + \"3\")"
           cmd: "echo $(expr \"1\" + \"3\")"
           say_template: "{{ output }}"
           say_template: "{{ output }}"
-    signals:
-      - order: "addition"
 ```
 ```
 
 
-Let's use a file template. We try to remove the file `~/test.txt` and make Kalliope gice us the result depending of the 
+Let's use a file template. We try to remove the file `~/test.txt` and make Kalliope give us the result depending of the 
 returned error code.
 returned error code.
 If the file is present on the system, you will hear "The command has succeeded" and so the file has been deleted. 
 If the file is present on the system, you will hear "The command has succeeded" and so the file has been deleted. 
 If you run it a second time, the command will fail as the file is not anymore present and so you should hear 
 If you run it a second time, the command will fail as the file is not anymore present and so you should hear 
 "The command has failed". See the template example bellow.
 "The command has failed". See the template example bellow.
 ```
 ```
-  - name: "remove a file"
+  - name: "remove-a-file"
+    signals:
+      - order: "remove file"
     neurons:
     neurons:
       - shell:
       - shell:
           cmd: "rm ~/test.txt"
           cmd: "rm ~/test.txt"
           file_template: remove_file.j2
           file_template: remove_file.j2
-    signals:
-      - order: "rm file"
 ```
 ```
 
 
 ## Templates example 
 ## Templates example 

+ 2 - 2
neurons/sleep/README.md

@@ -20,11 +20,11 @@ Simple example :
 
 
 ```
 ```
   - name: "run-simple-sleep"
   - name: "run-simple-sleep"
+    signals:
+      - order: "Wait for me "
     neurons:
     neurons:
       - sleep:
       - sleep:
           seconds: 60
           seconds: 60
-    signals:
-      - order: "Wait for me "
 ```
 ```
 
 
 
 

+ 13 - 13
neurons/systemdate/README.md

@@ -29,23 +29,23 @@ Give the current time from the system where Kalliope is installed. Return a dict
 
 
 Simple synapse that give the current time with only hours and minutes
 Simple synapse that give the current time with only hours and minutes
 ```
 ```
- - name: "time"
-    neurons:
-      - systemdate:
-          say_template:
-            - "It' {{ hours }} hours and {{ minutes }} minutes"
-    signals:
-      - order: "what time is it"
+- name: "time"
+  signals:
+    - order: "what time is it"
+  neurons:
+    - systemdate:
+        say_template:
+          - "It' {{ hours }} hours and {{ minutes }} minutes"   
 ```
 ```
 
 
 Synapse that give complete date and time with a template file.
 Synapse that give complete date and time with a template file.
 ```
 ```
- - name: "time"
-    neurons:
-      - systemdate:
-          file_template: en_systemdate_template_example.j2            
-    signals:
-      - order: "what time is it"
+- name: "time"
+  signals:
+    - order: "what time is it"
+  neurons:
+    - systemdate:
+        file_template: en_systemdate_template_example.j2
 ```
 ```
 
 
 
 

+ 9 - 9
neurons/tasker_autoremote/Readme.md

@@ -34,15 +34,15 @@ None
 
 
 Description of what the synapse will do
 Description of what the synapse will do
 ```
 ```
- - name: "find my phone"
-    neurons:
-      - say:
-          message: "I'll make your phone ringing, sir"
-      - tasker_autoremote:
-          key: "MY_VERY_LONG_KEY"
-          message: "lost"
-    signals:
-      - order: "where is my phone"
+- name: "find-my-phone"
+  signals:
+    - order: "where is my phone"
+  neurons:
+    - say:
+        message: "I'll make your phone ringing, sir"
+    - tasker_autoremote:
+        key: "MY_VERY_LONG_KEY"
+        message: "lost"
 ```
 ```
 
 
 
 

+ 10 - 10
neurons/twitter/README.md

@@ -24,16 +24,16 @@ This neuron allows you to send a tweet on your timeline.
 
 
 ```
 ```
 - name: "post-tweet"
 - name: "post-tweet"
-    neurons:
-      - twitter:
-          consumer_key: ""
-          consumer_secret: ""
-          access_token_key: ""
-          access_token_secret: ""
-          args:
-            - tweet
-    signals:
-      - order: "post on Twitter {{ tweet }}"
+  neurons:
+    - twitter:
+        consumer_key: ""
+        consumer_secret: ""
+        access_token_key: ""
+        access_token_secret: ""
+        args:
+          - tweet
+  signals:
+    - order: "post on Twitter {{ tweet }}"
 ```
 ```
 
 
 ## Notes
 ## Notes

+ 14 - 14
neurons/wake_on_lan/README.md

@@ -22,25 +22,25 @@ None
 
 
 Kalliope will send a magic packet to the mac address `00-00-00-00-00-00`
 Kalliope will send a magic packet to the mac address `00-00-00-00-00-00`
 ```
 ```
-- name: "wake my PC"
-    neurons:
-      - wake_on_lan:
-          mac_address: "00-00-00-00-00-00"
-    signals:
-      - order: "wake my PC"
+- name: "wake-my-PC"
+  signals:
+    - order: "wake my PC"
+  neurons:
+    - wake_on_lan:
+        mac_address: "00-00-00-00-00-00"
 ```
 ```
 
 
 If your broadcast address is not 255.255.255.255, or if your ethernet card does not listen on the standard 9 port, you can override default parameters.
 If your broadcast address is not 255.255.255.255, or if your ethernet card does not listen on the standard 9 port, you can override default parameters.
 In the following example, we suppose that kalliope is on a local areal network 172.16.0.0/16. The broadcast address would be 172.16.255.255.
 In the following example, we suppose that kalliope is on a local areal network 172.16.0.0/16. The broadcast address would be 172.16.255.255.
 ```
 ```
-- name: "wake my PC"
-    neurons:
-      - wake_on_lan:
-          mac_address: "00-00-00-00-00-00"
-          broadcast_address: "172.16.255.255"
-          port: 7
-    signals:
-      - order: "wake my PC"
+- name: "wake-my-PC"
+  signals:
+    - order: "wake my PC"
+  neurons:
+    - wake_on_lan:
+        mac_address: "00-00-00-00-00-00"
+        broadcast_address: "172.16.255.255"
+        port: 7
 ```
 ```
 
 
 ## Notes
 ## Notes

+ 9 - 8
neurons/wikipedia/README.md

@@ -33,14 +33,15 @@ Get the summary of a Wikipedia page.
 This synapse will look for the {{ query }} spelt by the user on Wikipedia
 This synapse will look for the {{ query }} spelt by the user on Wikipedia
 ```
 ```
 - name: "wikipedia-search"
 - name: "wikipedia-search"
-    neurons:
-      - wikipedia:
-          language: "en"
-          args:
-            - query
-          file_template: "wikipedia_returned_value.j2"
-    signals:
-      - order: "look on wikipedia {{ query }}"
+  signals:
+    - order: "look on wikipedia {{ query }}"
+  neurons:
+    - wikipedia:
+        language: "en"
+        args:
+          - query
+        file_template: "wikipedia_returned_value.j2"
+
 ```
 ```
 
 
 ## Templates example 
 ## Templates example 

+ 12 - 9
templates/fr_gmail.j2

@@ -1,9 +1,12 @@
-Vous avez {{ unread }} i-maile
-
-{% set count = 1 %}
-{% if unread > 0 %}
-    {% for subject in subjects %}
-     i-maile {{ count }}. {{ subject }}
-     {% set count = count + 1 %}
-    {% endfor %}
-{% endif %}
+{% if unread == 0 %}
+    Vous n'avez aucun email
+{% else %}
+    Vous avez {{ unread }} email.
+    {% set count = 1 %}
+    {% if unread > 0 %}
+        {% for subject in subjects %}
+         i-maile {{ count }}. {{ subject }}.
+         {% set count = count + 1 %}
+        {% endfor %}
+    {% endif %}
+{% endif %}

+ 5 - 0
templates/fr_gmail_count_unread.j2

@@ -0,0 +1,5 @@
+{% if unread == 0 %}
+    Vous n'avez aucun email.
+{% else %}
+    Vous avez {{ unread }} email.
+{% endif %}