Announcement

Collapse
No announcement yet.

Using Tasker to set home occupancy status

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using Tasker to set home occupancy status

    So I've been tinkering and researching during my free time recently, and it seems there is some interest in some of the things I've managed to set up. I'm sure there are many out there who will find this boring and won't learn much, but I'm sure there are many more who will benefit from some of what I've learned. I'm going to detail how to create a Tasker Profile and Tasks to create a home occupancy tracker.

    My goal when I decided to give tasker a try was to use my home automation system to actually, you know, automate my home more. I mean, I love HS Touch and I use it (along with a custom layout) to control my televisions via globalcache IR devices. I also enjoy being able to control the attic fan, outside flood lights, gazebo lighting, and other remote devices from anywhere with Homeseer. But I found that there was a decided lack of automation in my home automation system. That's what led me to Tasker, and to posting this how-to.

    So to begin with, you'll need an Android smartphone and a copy of Tasker. I believe I paid $5 for it, and it is SOOO worth every penny. If you are interested in learning more advanced Tasker usage, check out this link. You'll need to have HS web server remote access enabled for this to work and for simplicity's sake, a dynamic DNS service. You also need a wifi router at home, though you don't need to connect to it if you choose not to.

    Alright, down to business:

    To get started, launch Tasker and select the Profiles tab. At the bottom of the screen, press the + symbol to add a context (condition) that will control when the profile should be active. Click on State, then choose the Net icon. Finally, select the Wifi Near state to indicate that we want to check for the presence of a wifi network as our trigger. On the next screen, click the magnifying glass on the SSID line, and choose your home wifi from the list. Now simply click the back button ONCE to complete the profile context.

    The next thing we need to do is create a task that will be triggered whenever the "At home" Tasker profile is activated. You should see a pop-up with the heading Enter Task. Click on New Task +, and then type a name for your task. Something like "Activate Home" should work nicely. Click the check mark, and you should be brought to the Task Edit screen. Do as it says, and click the + button to add an action.

    Now we have some options. We can choose to control a virtual device, and use an event to trigger HS actions, or we can run an event directly from Tasker. For my setup (which I will assume you are duplicating), I created a "Wes Location" virtual device in Homeseer with value-status pairs as shown here:



    In order to directly control a device with an HTTP request (whether a similar virtual device, or any other) you need to know it's device reference ID. This can be found on the Additional Information tab of our new virtual device's properties. Keep this number handy, as we'll need it in a moment.

    Back to Tasker... To communicate with HS, we're going to use HTTP Post requests. So click on Net, then HTTP Post. On the Server:Port line, you'll use the following format to reach your HS server: Username:Password@yourDDNS:homeseerport. So if your HS web server username is mickey, password is mouse, and your server is configured on port 80, enter mickey:mouse@yourdomain.com:80 In the Path field, enter "/stif", with the / but without the quotes. In the Data/File field, enter the following two lines:

    control_device=xxxx
    selectvalue=X

    where xxxx is the device reference ID, and X is the device value that indicates Home.

    That almost does it. Now we only need to create a task that changes the status to Away when not near home wifi. So click the back arrow to return to the Task Edit screen. To make the last step easier, I suggest long pressing on the HTTP Post line we've just created. This will bring up some edit options. Click the copy icon. Then we want to click the back button again to return to the profiles list. You should see your Activate Home task with a green arrow next to it. Long press on this task, and from the popup, select Add Exit Task. Now once again select New Task +, and enter a name such as Activate Away. On the Task Edit screen, long-press on the white background and select Paste from the popup. Now select the HTTP Post command you just pasted. The only thing that needs to change here is the value of the "selectvalue=". Change it to whatever indicates you are now away from home.

    The last thing I would recommend doing is to rename the profile we created in Tasker. To do this, return to the profile screen using the back arrow. Then just long press on the Wifi Near ... profile and click the A that appears in the top menu bar. Input a name and select the check mark to save. Your work in Tasker should be done.

    Now just dream up all of the cool things that location awareness can add to Homeseer and add a bit more automation to your day.

    If you would like to directly trigger a Homeseer event, there are a few changes you need to make to the HTTP Post command. On the Path line, change /stif to /evls. On the Data/File line, enter run_event=xxxxxx, where xxxxxx is the exact name of your event. Thanks to CocoonTech for that tidbit.

    Enjoy!

    WeaslyD
    Last edited by weaslyd; July 1, 2013, 08:36 PM. Reason: Title correction

    #2
    Originally posted by weaslyd View Post
    So I've been tinkering and researching during my free time recently, and it seems there is some interest in some of the things I've managed to set up. I'm sure there are many out there who will find this boring and won't learn much, but I'm sure there are many more who will benefit from some of what I've learned. I'm going to detail how to create a Tasker Profile and Tasks to create a home occupancy tracker.

    My goal when I decided to give tasker a try was to use my home automation system to actually, you know, automate my home more. I mean, I love HS Touch and I use it (along with a custom layout) to control my televisions via globalcache IR devices. I also enjoy being able to control the attic fan, outside flood lights, gazebo lighting, and other remote devices from anywhere with Homeseer. But I found that there was a decided lack of automation in my home automation system. That's what led me to Tasker, and to posting this how-to.

    So to begin with, you'll need an Android smartphone and a copy of Tasker. I believe I paid $5 for it, and it is SOOO worth every penny. If you are interested in learning more advanced Tasker usage, check out this link. You'll need to have HS web server remote access enabled for this to work and for simplicity's sake, a dynamic DNS service. You also need a wifi router at home, though you don't need to connect to it if you choose not to.

    Alright, down to business:

    To get started, launch Tasker and select the Profiles tab. At the bottom of the screen, press the + symbol to add a context (condition) that will control when the profile should be active. Click on State, then choose the Net icon. Finally, select the Wifi Near state to indicate that we want to check for the presence of a wifi network as our trigger. On the next screen, click the magnifying glass on the SSID line, and choose your home wifi from the list. Now simply click the back button ONCE to complete the profile context.

    The next thing we need to do is create a task that will be triggered whenever the "At home" Tasker profile is activated. You should see a pop-up with the heading Enter Task. Click on New Task +, and then type a name for your task. Something like "Activate Home" should work nicely. Click the check mark, and you should be brought to the Task Edit screen. Do as it says, and click the + button to add an action.

    Now we have some options. We can choose to control a virtual device, and use an event to trigger HS actions, or we can run an event directly from Tasker. For my setup (which I will assume you are duplicating), I created a "Wes Location" virtual device in Homeseer with value-status pairs as shown here:



    In order to directly control a device with an HTTP request (whether a similar virtual device, or any other) you need to know it's device reference ID. This can be found on the Additional Information tab of our new virtual device's properties. Keep this number handy, as we'll need it in a moment.

    Back to Tasker... To communicate with HS, we're going to use HTTP Post requests. So click on Net, then HTTP Post. On the Server:Port line, you'll use the following format to reach your HS server: Username:Password@yourDDNS:homeseerport. So if your HS web server username is mickey, password is mouse, and your server is configured on port 80, enter mickey:mouse@yourdomain.com:80 In the Path field, enter "/stif", with the / but without the quotes. In the Data/File field, enter the following two lines:

    control_device=xxxx
    selectvalue=X

    where xxxx is the device reference ID, and X is the device value that indicates Home.

    That almost does it. Now we only need to create a task that changes the status to Away when not near home wifi. So click the back arrow to return to the Task Edit screen. To make the last step easier, I suggest long pressing on the HTTP Post line we've just created. This will bring up some edit options. Click the copy icon. Then we want to click the back button again to return to the profiles list. You should see your Activate Home task with a green arrow next to it. Long press on this task, and from the popup, select Add Exit Task. Now once again select New Task +, and enter a name such as Activate Away. On the Task Edit screen, long-press on the white background and select Paste from the popup. Now select the HTTP Post command you just pasted. The only thing that needs to change here is the value of the "selectvalue=". Change it to whatever indicates you are now away from home.

    The last thing I would recommend doing is to rename the profile we created in Tasker. To do this, return to the profile screen using the back arrow. Then just long press on the Wifi Near ... profile and click the A that appears in the top menu bar. Input a name and select the check mark to save. Your work in Tasker should be done.

    Now just dream up all of the cool things that location awareness can add to Homeseer and add a bit more automation to your day.

    If you would like to directly trigger a Homeseer event, there are a few changes you need to make to the HTTP Post command. On the Path line, change /stif to /evls. On the Data/File line, enter run_event=xxxxxx, where xxxxxx is the exact name of your event. Thanks to CocoonTech for that tidbit.

    Enjoy!

    WeaslyD
    See Snelv Latitude. It puts location awareness into Homeseer. It is in the scripts folder. It uses Google Latitude OR Btraced to do location awareness. You can use Apple or Android products. Probably even Windows and Blackberry.

    I once used Tasker to do something similar to what you did. Google Latitude seems to use GPS and wifi to keep a database of WIFI access points so it gets pretty accurate. The disadvantage to the Tasker approach is that you go into your yard to get the mail-- loose wifi and the house reacts. Latitude will update your location when you move.

    The added beauty is you can have events trigger when you are approaching and when you are leaving. It knows distance.

    I do see a lot of potential for putting some smarts in the phone with Tasker. You might be able to do something along the lines of "Joe's phone is paired with the Mazda and he is driving around". Maybe Joe only takes the Mazda when he goes on vacation. Or Joe's on the phone and in the house-- turn down the music.
    HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

    Plug-Ins Enabled:
    Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
    weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

    Comment


      #3
      I agree lattitude would be better/more flexible, remember that it causes quite a battery drain !

      I only use 'location' reporting for when I enter or leave the home, the other (to me) are of no interest.

      In tasker you can also specify a 'perimeter'. Also check the new tasker plugin "AutoLocation": this supports geofences (but might take a load on your battery ...)

      Comment


        #4
        Originally posted by wpiman View Post
        See Snelv Latitude. It puts location awareness into Homeseer. It is in the scripts folder. It uses Google Latitude OR Btraced to do location awareness. You can use Apple or Android products. Probably even Windows and Blackberry.

        I once used Tasker to do something similar to what you did. Google Latitude seems to use GPS and wifi to keep a database of WIFI access points so it gets pretty accurate. The disadvantage to the Tasker approach is that you go into your yard to get the mail-- loose wifi and the house reacts. Latitude will update your location when you move.

        The added beauty is you can have events trigger when you are approaching and when you are leaving. It knows distance.

        I do see a lot of potential for putting some smarts in the phone with Tasker. You might be able to do something along the lines of "Joe's phone is paired with the Mazda and he is driving around". Maybe Joe only takes the Mazda when he goes on vacation. Or Joe's on the phone and in the house-- turn down the music.
        Wpiman

        I am aware of several other ways to do location awareness/home occupancy. My goal here was to instruct others in a method that works with Tasker - an application many are already using for other purposes. I think Snevl Latitude looks cool, but I have no need for precise geographic location.

        If you look into Tasker, "losing wifi" on the way to the mailbox is not an issue for most. I have a 200+ foot long driveway and a modern router, so I get signal all the way there. Also Tasker is smart enough not to activate a profile on just a moment's loss of signal. By default, it requires a wifi network to be out of range for 2x the wifi re-scan period - 90 seconds by default. Both of those numbers are adjustable by the user however, so that one 30 second lapse could be set up if preferred.

        As for the other Tasker profile ideas you mention, I use similar ones now. For example, Tasker tells HS when I arrive at work. Later when I leave work, Tasker checks my current location by GPS 10 mins later. If I am closer to home than the distance to work, and also moving at greater than 15 miles per hour, my air conditioning is turned on.

        When I receive a call, Tasker tells HS to pause the television - but only if I'm at home. When the call ends, playback is restarted.

        There are others, but you get the idea. I am already using Tasker for several tasks, so it was natural to use for home occupancy/location.

        WeaslyD

        Comment


          #5
          Tasker is an awesome application. I really wish there was something similar for the iPhone...

          Comment


            #6
            I wonder if it would be possible to put something similar into HSTouch itself so that scripts could be written to work on any particular phone platform; iOS or Android. That seems the natural way to handle it. I don't imagine it could be all that hard.

            I have tasker on an Android phone but am currently carrying an iPhone. I have both an Android tablet and iPad. Seemly integration would be ideal.
            HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)

            Plug-Ins Enabled:
            Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
            weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:

            Comment


              #7
              How do I directly control a light switch? I have it working with the events but when I try to control a device with the selectvalue it changes the value on with webpage but the device does not turn on. Is there a set status command?

              Comment


                #8
                Can anyone tell me how to send an HS device status to tasker so I can display the status Minimalistic Text Widget?
                Thanx

                Comment


                  #9
                  Originally posted by comgle64 View Post
                  How do I directly control a light switch? I have it working with the events but when I try to control a device with the selectvalue it changes the value on with webpage but the device does not turn on. Is there a set status command?
                  Comgle64,

                  Sorry I didn't see your post sooner, but I have an answer if you still need it. I failed to mention in it my initial post, but to control a device's on/off status you use the following options in the Tasker data/file field:

                  control_device=xxxx
                  action_on=on (or action_off=off)

                  Hope that helps!

                  WeaslyD

                  Comment


                    #10
                    Search for speechdroid, it's about the same thing, gives you a foundation to start with, regarding controlling HS with Tasker and voice commands.

                    Sent from my SCH-I45 using Tapatalk 4
                    HS: 2.5.0.60
                    Environment: Virtual XP as guest in VMWare Server running under Win 7
                    Plug-ins: MLHSPlugin|RCS Serial Thermostat|UltraLog|UltraMon|
                    Misc: 303 Devices, 313 Events, 68+ Scripts

                    HSeer: 3.0.0.54
                    Environment: Virtual XP as guest in VMWare Server running under Win 7
                    Plug-ins: BLGData|BLRF|BLRadar|BLRandom|BLSpeech
                    UltraM1G3|UltraECM3|UltraMon3|UPBSpud|Z-Wave
                    Misc: 148 Devices, 116 Events, 9+ Scripts (so far, still converting)

                    Comment


                      #11
                      Originally posted by jrjmpls7 View Post
                      Can anyone tell me how to send an HS device status to tasker so I can display the status Minimalistic Text Widget?
                      Thanx
                      Check out autoremote. This will allow sending data to tasker and display it in Minimalistic Text

                      Comment


                        #12
                        Only thing I do not like about Autoremote, is you need to send messages through a server you do not control. I know, it's just something I'm trying to do - use only my OWN servers and what-not.

                        --Dan
                        Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

                        Comment


                          #13
                          Hey WeseldyD,

                          I did finally figure it out. My new question is, is there a way to send a variable? What I mean is I would like to say "Dim living room lights to 50%. I don't want to have to create a task for every dim percentage. I read something about using variables but not quite sure how to set it up.
                          Thanks for the help.
                          Originally posted by weaslyd View Post
                          Comgle64,

                          Sorry I didn't see your post sooner, but I have an answer if you still need it. I failed to mention in it my initial post, but to control a device's on/off status you use the following options in the Tasker data/file field:

                          control_device=xxxx
                          action_on=on (or action_off=off)

                          Hope that helps!

                          WeaslyD

                          Comment


                            #14
                            Re: Using Tasker to set home occupancy status

                            Originally posted by comgle64 View Post
                            Hey WeseldyD,

                            I did finally figure it out. My new question is, is there a way to send a variable? What I mean is I would like to say "Dim living room lights to 50%. I don't want to have to create a task for every dim percentage. I read something about using variables but not quite sure how to set it up.
                            Thanks for the help.

                            Well first off, to dim a device you should replace the "action_on=on" command with "selectdim=XX" to directly set the dim value to XX. Using Tasker, it is exceedingly simple to replace the XX in the command to a variable, say %Dimval, the value of which you can set in using the Variable Set action in Tasker.

                            So for example, if you are parsing a spoken phrase you could use Variable Set to store the value spoken directly before the word "percent" into the variable %Dimval, then send an HTTP Post command to Homeseer with "selectdim=%Dimval" in the Data/File field.

                            Hope that answers your question!

                            WeaslyD


                            Sent from my Xoom using Tapatalk 2


                            Another quick pointer just occured to me...

                            If you are in fact using this method to create a voice control app with Tasker, you may want to consider changing the "control_device=" reference. When i was first working on controlling HS with Tasker, I read instructions that advised using the device reference ID. This is fine for setting up a single control task, but not so much when using speech to tell Tasker which device to control (unless you want to remember every dev ref ID). I have since played around and discovered that using the room name + device name works as well. So for example, to turn on the sconces in my living room, i use "control_device=living room wall light" instead of "controldevice=7773" as i was using. Obviously a bit easier for voice control...
                            Last edited by weaslyd; August 21, 2013, 04:53 PM.

                            Comment


                              #15
                              Thanks for the response. It does make sense but I still need a little help. Im new to this whole variable thing. What is the syntax for storing the value befor "percent"?

                              Comment

                              Working...
                              X