+2

New bOS's RPC API + Tasker | Tutorial

ComfortClick ComfortClick 5 years ago in Devices / Other updated by Brent Broge 5 years ago 1

Hello!

Here we have a short tutorial on how to integrate bOS and TASKER using new bOS’ RPC service.

bOS offers a JSON RPC Service for integration with Tasker, IFTTT and other services.

This tutorial will show bOS RPC service interacting with TASKER on Android in a simple task, but the important thing here is to understand how to set-up the RPC service so you can do more complex integrations.

RPC service on the new bOS offers HTTP basic authentication with username and password.

In this example, we'll be using Tasker to turn a Z-Wave Socket off.

Of course, this can be done easily within bOS Client app, but this is just for demo purposes. You can change and adapt the task to your needs, for example, "If my phone battery is lower than 80%, turn the socket on", or "If I’ve reached my house, turn front door light on". The possibilities are endless.

Step 1: Configure your RPC service

  • In bOS Configurator, under API, enable RPC and define your Username and Password:

Image 2046


Step 2: Find your Device Path

  • In this example, the Info tab from the Z-Wave socket device will show us the path: Devices\Z-Wave\Socket\Basic

Image 2047


Now we need to form the JSON body to POST on TASKER.

The Path we have is: Devices\Z-Wave\Socket\Basic

We need to double the backslashes on the Path to form the JSON body to POST on TASKER service, so now we have: Devices\\Z-Wave\\Socket\\Basic

The simple SetValue body post looks something like this:

{"objectName":"INSERT PATH HERE","valueName":"Value","value":"true"} where "value":"true" is to turn the value to true or 1. You can change to false or 0 or look for other RPC examples.

For our valueName, we have “State”:

Image 2048

To turn the Socket off, our body post is:

{"objectName":"Devices\\Z-Wave\\Socket\\Basic","valueName":"State","value":"false"}

Step 3: Tasker

  • Create a new task and include the “HTTP Post” action:
    Image 2050

Image 2051

Done! Now every time we run this task our Socket will turn off.

This is a simple example for demo purposes, but with more complex commands you can do whatever you want... call scenes, set other values, etc.

To call a RPC Service a HTTP POST call must be preformed with data content-type = "application/json";

Service offers the following commands

http://localhost:81/SetValue

POST data example (Turn ON a light): {"objectName":"Devices\\EIB\\Light 1","valueName":"Value","value":"true"}

http://localhost:81/GetValue

POST data example (Get light status): {"objectName":"Devices\\EIB\\Light 1","valueName":"Value"}

http://localhost:81/CallFunction

POST data example (Send alert to user):

{"objectName":"Building\\General\\Users\\User","functionName":"SendAlert","value":["'Hello'"]}

I hope you’ve enjoyed the tutorial and please post here the examples and ideas you have using the new bOS’ RPC API.