Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blocks:app-note:flic [2024-03-22 13:22]
mattias [Use Flic wireless buttons as a triggers in Blocks]
blocks:app-note:flic [2024-03-22 14:03] (current)
mattias [Configure the button action]
Line 1: Line 1:
 =====Use Flic2 wireless buttons as a triggers in Blocks===== =====Use Flic2 wireless buttons as a triggers in Blocks=====
  
-This application note is technical but gives anexample on how to use the example user script SimpleHttpInput to make something happen in a Blocks system from the push of a Flic button. +This application note is technical but gives an example on how to use the example user script SimpleHttpInput to make something happen in a Blocks system from the push of a wireless button. 
  
  
 +====Requirements====
 +Flic2 button is the only hardware required.
 +
 +{{:blocks:app-note:flic:flibutton.png?200|}}
 +
 +Flic Hub LR with a ehternet connection is recommended for any real application but optional for testing.
 +
 +{{:blocks:app-note:flic:flic.png?400|}}
 ====The devices==== ====The devices====
-The Flic2 buttons is communication over BLE (bluetooth low energy) with a mobile device or with a Flic hub. + 
-A button can trigger three different commands depending of if it is a Push, a long Push and Hold or a Double Push. + 
 +The Flic2 buttons is a Swedish crowdfunded project by [[https://flic.io|Shortcut Labs AB]]. 
 + The buttons communicate over BLE (bluetooth low energy) using a mobile device or a Flic hub as the reciever
 +A button can trigger three different commands depending on if it is a Push, a long Push and Hold or a Double Push. 
  
  
 ====Setup==== ====Setup====
-In short, one must download the Flic app from app-store or play-store and follow the vendors instruction to connect the buttons to the app or add a hub. +Download the Flic app from app-store or play-store and follow the vendors instructions to connect the buttons to the app or add a hub.
  
 ====Setup in Blocks==== ====Setup in Blocks====
 Copy the example script SimpleHttpInput.js file from /script/user-archive to /script/user (found in your blocks root directory) to make it active and available for the Blocks server. Restart the server.  Copy the example script SimpleHttpInput.js file from /script/user-archive to /script/user (found in your blocks root directory) to make it active and available for the Blocks server. Restart the server. 
  
-====Configure the Flic buttons action====+====Configure the button action====
 Follow the vendors documentation to find how to add hub actions to the button in the Flic application.  Follow the vendors documentation to find how to add hub actions to the button in the Flic application. 
 Select the Internet Request action.  Select the Internet Request action. 
  
 Set the method to GET. Set the method to GET.
-Enter your server details in the URL like in the exampel below:+Enter your server details in the URL in this format:
 <code> <code>
-http://<SERVER><:PORT-IF-REQUIRED>/rest/script/invoke/SimpleHttpInput/message/<YOUR-MESSAGE>+http(s)://<SERVER><:PORT-IF-REQUIRED>/rest/script/invoke/SimpleHttpInput/message/<YOUR-MESSAGE>
 </code> </code>
 Example: Example:
Line 36: Line 47:
 =====Trigger a task==== =====Trigger a task====
  
-The user script exposes the lastMessage in blocks. If a message is received the property's value will briefly contain the message. +The user script exposes the //lastMessage//  property in blocks. If a message is received the property's value will briefly contain the message. 
 Add a task and use the lastMessage property as a trigger like in the example screen shot. Add a task and use the lastMessage property as a trigger like in the example screen shot.
-We can also use some if statement to perform different actions depending on what message was recieved+We can also use some if statement to perform different actions depending on what message was received
  
 {{:blocks:app-note:flic:flictask.png?800|}} {{:blocks:app-note:flic:flictask.png?800|}}