Tasker Cloud Variables - Store variables in the cloud

Learn how to use the jsonbin.org API to store and read data in the cloud

  1. joaomgcd
    In this example we're going to set the "home" or "away" status for each device in the cloud and then read that status from any of those devices.

    This project should be setup on every device you wish to monitor the status of.

    This way you can read and write to a list of variables that's common to all the devices you own!

    When you're done with this project you'll be able to tell if all devices are home or not.

    To start import the Jsonbin.org API in AutoWeb and enter your API key from here: https://jsonbin.org/_/login

    STEP 1 - SET VALUE FOR HOME


    • Add a new profile with the Wifi Connected state (or whatever state you use to control your at home status)
    • Set the network name to your home network name
    • In the task add a new AutoWeb Web Service action
    • Select the Jsonbin.org API
    • Select the Set Data For Key action
    • In the key write %DEVMOD
    (i) %DEVMOD contains your device model name, so by using this as the key every device you have will have a different key.
    • In the value write home


    STEP 2 - SET AWAY


    • Copy the AutoWeb action you just created
    • Add an exit Task to the profile
    • Paste the AutoWeb action
    • In the action change the home value to away


    After creating this profile export it and then import it on all your devices so that every device you have sets its own key in the cloud with its home or away status, depending on if it's connected to the network or not.

    Now we can read what everyone's status is

    STEP 3 - GET ALL DATA


    • Create a new Task called Is Everyone Home
    • Add an AutoWeb Web Service action
    • Select the Jsonbin.org API
    • Select the Get All Data action
    • In Output -> Fields to get select the Get all data Output option
    • Add a flash action to show the data you get


    STEP 4 - READ DATA FOR EACH DEVICE AND CHECK IF EVERYONE'S HOME


    • Add an AutoTools Json Read action
    • Set the input to %getall_output and the fields to the names of your devices seperated by commas (in my case Pixel,Nexus 5X)
    • Flash the values for these
    • Add an AutoTools Text action
    • Set the Text field to all the device variables you got (in my case %pixel%nexus5x)
    • Under Matching set Match Text to homehome (which is what we expect when both devices are home)
    • Enable Exact
    • Add a flash action with %atmatches()


    In the end %atmatches() will contain true if every device status is home and false if not.
    You can use this value wherever you like to do what you need to on your device! :cool: