Announcement

Collapse
No announcement yet.

Basic help with setting Tasker variables for a newbie?

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

    Basic help with setting Tasker variables for a newbie?

    My old HAC died and am very interested in switching to HS3 - that being said, I have 0 experience with this platform so far so please forgive me..

    Tasker is a big part of my existing automations, primarily revolving around custom variables set in tasker. E.g. incoming AutoRemote message MOTION=:=1 triggers a task, which sets %MOTION to 1 to control the motion sensor in a given room. While the motion sensor itself would be handled by HS3, it is important I am able to "push" this status update to my Android devices running Tasker so they "know" what the current status of my devices are, allowing me to view a homescreen widget that shows me that status at a glance via an icon for example..

    The primary difference it would seem now, instead of using AutoRemote to send variable status updates, I would now be using the "Control a Device" event action using the Tasker plugin in HS3... The default event action seems like it's built to set %DeviceString on the recipient Tasker device which can trigger a variety of built-in functions TonIof has programmed himself..

    What I would like to know how to do, is use this event action in HS3 to, for example set my own custom variables, say for example, I want to set %Motion to 1. Can anyone provide any help how or if I even can do this exactly? I am hoping the custom code option would allow this, but am very new to HS3.

    #2
    I am assuming you mean sending a message from HS3 to your phone (or tablet) to set a Tasker Variable.

    I do this using the Autoremote Tasker plugin. When you set up the Autoremote plugin, you get a special URL that you can use to send to the phone. Then simply set up some parameters so that the phone, when receiving the HTTP message, can make sense of it. To send a URL from HS3, you will need to do a little bit of scripting, but if you are fluent in Tasker, the VB .net language (used by HS3) should be relatively easy to pick up.

    Comment


      #3
      I use autoremote and tasker to send push messages from HS3 an Android tablet in my kitchen. Here is my script code:

      Code:
       Public Sub Main(ByVal Parms As Object)
              Dim p, rc As String
              Dim BaseUrl As String = "https://autoremotejoaomgcd.appspot.com/sendmessage?key=xxxxxxxxxxxxxxxxR7JCIn0U9wANOF5IvypnwrWeL9hxVnKktxudSif3cKF7wiitDvruakL7vkALihZuEn39fpsLNqblWJJwnV7yGU5KFN9RfKQXgqqvOe4q8Fk_bEJQlPmYR4n5FrbocKuEDUYtICglb4iNA5olLCd2TWNYWSYM2GBtrNC_QXZoXI&message="
      
              p = Parms.ToString
              hs.WriteLog("SendToTablet", p)
              rc = SendPush(BaseUrl & p)
              If rc <> "OK" Then
                  hs.WriteLog("SendToTablet", "Bad RC from SendPush: " & rc)
                  hs.WriteLog("SendToTablet", "URL: " & BaseUrl & p)
              End If
          End Sub
          Function SendPush(ByVal sURL As String) As String
              Dim strData As String = ""
              Dim tlRequest As System.Net.HttpWebRequest
              Dim tlResponse As System.Net.HttpWebResponse
              Dim tlStatusCode As Integer
              Try
                  tlRequest = CType(System.Net.WebRequest.Create(sURL), System.Net.HttpWebRequest)
                  tlRequest.ContentType = "text/html"
                  tlRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
                  tlRequest.Method = "GET"
                  tlRequest.Timeout = 10000
                  tlRequest.AllowAutoRedirect = True
                  tlResponse = CType(tlRequest.GetResponse(), System.Net.HttpWebResponse)
                  tlStatusCode = tlResponse.StatusCode
                  If tlStatusCode = System.Net.HttpStatusCode.OK Then
                      strData = New System.IO.StreamReader(tlResponse.GetResponseStream()).ReadToEnd()
                  Else
                      Return "Grab Error"
                  End If
                  tlResponse.Close()
              Catch ex As Exception
                  hs.WriteLog("SendToTablet", "HTTP Request Failed: " & ex.ToString)
              End Try
              Return strData
          End Function
      Tasker running on tablet detects autoremote messages and does different things, ie: displays weather maps when HS3 detects weather warnings.

      Let me know if I can help.
      tenholde

      Comment


        #4
        here is an event that detects house alarm, sends text "AlarmEntryDelay" to kitchen tablet. Autoremote Tasker task is triggered that then displays the alarm web page on the kitchen tablet.
        tenholde

        Comment


          #5
          Originally posted by tenholde View Post
          I use autoremote and tasker to send push messages from HS3 an Android tablet in my kitchen. Here is my script code:

          Code:
          Public Sub Main(ByVal Parms As Object)
          Dim p, rc As String
          Dim BaseUrl As String = "https://autoremotejoaomgcd.appspot.com/sendmessage?key=xxxxxxxxxxxxxxxxR7JCIn0U9wANOF5IvypnwrWeL9hxVnKktxudSif3cKF7wiitDvruakL7vkALihZuEn39fpsLNqblWJJwnV7yGU5KFN9RfKQXgqqvOe4q8Fk_bEJQlPmYR4n5FrbocKuEDUYtICglb4iNA5olLCd2TWNYWSYM2GBtrNC_QXZoXI&message="
          
          p = Parms.ToString
          hs.WriteLog("SendToTablet", p)
          rc = SendPush(BaseUrl & p)
          If rc <> "OK" Then
          hs.WriteLog("SendToTablet", "Bad RC from SendPush: " & rc)
          hs.WriteLog("SendToTablet", "URL: " & BaseUrl & p)
          End If
          End Sub
          Function SendPush(ByVal sURL As String) As String
          Dim strData As String = ""
          Dim tlRequest As System.Net.HttpWebRequest
          Dim tlResponse As System.Net.HttpWebResponse
          Dim tlStatusCode As Integer
          Try
          tlRequest = CType(System.Net.WebRequest.Create(sURL), System.Net.HttpWebRequest)
          tlRequest.ContentType = "text/html"
          tlRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
          tlRequest.Method = "GET"
          tlRequest.Timeout = 10000
          tlRequest.AllowAutoRedirect = True
          tlResponse = CType(tlRequest.GetResponse(), System.Net.HttpWebResponse)
          tlStatusCode = tlResponse.StatusCode
          If tlStatusCode = System.Net.HttpStatusCode.OK Then
          strData = New System.IO.StreamReader(tlResponse.GetResponseStream()).ReadToEnd()
          Else
          Return "Grab Error"
          End If
          tlResponse.Close()
          Catch ex As Exception
          hs.WriteLog("SendToTablet", "HTTP Request Failed: " & ex.ToString)
          End Try
          Return strData
          End Function
          Tasker running on tablet detects autoremote messages and does different things, ie: displays weather maps when HS3 detects weather warnings.

          Let me know if I can help.
          Thank you, I think this is what I am looking for, I just didn't realize the Tasker plugin wasn't required. Question though,
          1. Besides the AutoRemote URL, which I know how to obtain and see where to edit that in your script - is there anything else I should modify? I was a little thrown off by the references to "Dim"
          2. It looks like the AutoRemote URL called out in the beginning of the script has the message payload left empty (;message=") - This is so the payload can be set via parameter in HS3 as shown in your photo in the second post, correct? I didn't quite get how that was being set in your script, but I will trust you know your way around VB better than I

          Comment


            #6
            Originally posted by ee21 View Post


            2. It looks like the AutoRemote URL called out in the beginning of the script has the message payload left empty (;message=") - This is so the payload can be set via parameter in HS3 as shown in your photo in the second post, correct? I didn't quite get how that was being set in your script, but I will trust you know your way around VB better than I
            Code:
             
             rc = SendPush(BaseUrl & p)
            This forum changed special characters to URL happy code. SendPush(BaseUrl & p) sends the BaseUrl with the script parameter appended to it.
            tenholde

            Comment


              #7
              Originally posted by ee21 View Post

              I was a little thrown off by the references to "Dim"
              The Dim statements define a varialbe as a specific type. In some cases, besides defining the type, an initial value is assigned.
              tenholde

              Comment


                #8
                Originally posted by ee21 View Post


                1. Besides the AutoRemote URL, which I know how to obtain and see where to edit that in your script - is there anything else I should modify?
                I think the only other thing to change is the
                & kind of references. ie, change & to an ampersand
                tenholde

                Comment


                  #9
                  Originally posted by tenholde View Post

                  I think the only other thing to change is the
                  & kind of references. ie, change & to an ampersand
                  I used find and replace to fix the & issue, and input my personal AutoRemote "key" as shown below, but this does not seem to work. Any ideas what I might be doing incorrectly? I can take the URL, add something at the end of "message=" enter it in a web browser, and the message goes through, HomeSeer sadly does not though. If any logs would help, let me know, I'm trying to poke around but sadly know basically 0 about troubleshooting HomeSeer so far.

                  Edit: Found this, issue seems obvious but I'm not sure how to fix the script, any assistance you can provide would be greatly appreciated!:
                  Jan-09 9:11:31 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\SendToSupreme.vb: Character is not valid.
                  Jan-09 9:11:31 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\SendToSupreme.vb: 'lt' is not declared. It may be inaccessible due to its protection level.
                  Jan-09 9:11:31 AM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\SendToSupreme.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
                  Click image for larger version  Name:	Screenshot (1).png Views:	0 Size:	23.7 KB ID:	1353016Click image for larger version

Name:	Screenshot (2).png
Views:	292
Size:	12.0 KB
ID:	1353018

                  Comment


                    #10
                    Actually managed to fix it myself, found the error based on another post you made on another thread, and I also manged to get the LAN IP to work too:
                    Click image for larger version

Name:	Screenshot (3).png
Views:	282
Size:	33.7 KB
ID:	1353563

                    Comment

                    Working...
                    X