AutoRemote Sending a Message from "Fibaro HC2" to "Android Tablet" with "Tasker WiFi Service" and "AutoRemote"

Discussion in 'AutoApps' started by okatzer, Apr 20, 2016.

  1. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    Hey, I want to send a message from "Fibaro HC2" to "Android Tablet" with "Tasker WiFi Service" and "AutoRemote"

    My configuration is:

    Androit Tablet:
    - "Tasker WiFi Service" is aktiv
    - "AutoRemote" registered
    - WiFi on and connected
    - no mobile data connection

    Fibaro HC2
    - Wifi on and connected
    - no mobile data connection
    Both systems are on the same WiFi network

    I try the folowing:

    1: send a request form HC2 to Tablet with
    - "Tasker WiFi Service" is aktiv
    - targetIP = '192.168.178.43'
    - AutoRemotePort = '1817'
    - targetKey = 'the_key'
    the request seams to be OK. I get a "response.status = 200"
    That means connection success

    2: send a request form HC2 to Tablet with
    - "Tasker WiFi Service" is aktiv
    - targetIP = 'wrong IP'
    - AutoRemotePort = '1817'
    - targetKey = 'the_key'
    the request seams to fail. I get a "response = connection refused"
    That means connection error.

    3: send a request form HC2 to Tablet with
    - "Tasker WiFi Service" is aktiv
    - targetIP = '192.168.178.43'
    - AutoRemotePort = 'wrong prt'
    - targetKey = 'the_key'
    the request seams to fail. I get a "response = connection refused"
    That means connection error.

    4: send a request form HC2 to Tablet
    - "Tasker WiFi Service" is disabled
    - targetIP = '192.168.178.43'
    - AutoRemotePort = '1817'
    - targetKey = 'the_key'
    the request seams to fail. I get a "response = connection refused"
    That means connection error.


    OK, Pos 1: seams to be the right way, but I get no log-entry in AutoRemote and no trigger in Tasker

    May be you can help me with this.

    By the way, the folowing code does work it sends a message with GCM
    -- Http-Request for AutoRemote & Tasker by GCM (Google Cloud Messaging)
    local function getMethod()
    local http = net.HTTPClient()
    Debug('blue', 'enter getMethod')
    http:request( 'https://autoremotejoaomgcd.appspot.com/sendmessage?key=the_key&message=DoIt',
    {
    options = {method = 'GET'},
    success = successCallback,
    error = errorCollback
    }
    )
    end


    thx in advance


    -------------------------------------------------------------------------------
    This is the relevant scene LUA code on "Fibaro HC2" to send to Tasker WiFi Service
    -------------------------------------------------------------------------------

    local targetIP = '192.168.178.43'
    local targetPort = '1817'
    local targetKey = 'the_key'

    -- Callback at success
    local function successCallback(resp)
    fibaro:debug('connection success, status: ' .. resp.status)
    end

    -- Callback at error
    local function errorCallback(resp)
    fibaro:debug('connection no success, error: ' .. resp)
    end

    -- http-request Scene : senden über AutoRemote Tasker WiFi Service enabled in Tasker Action

    local function getDirect(receiverIP, AutoRemotePort, SenderKey, Command)
    fibaro:debug('enter getDirect: ' .. receiverIP .. ':' .. AutoRemotePort)
    local http = net.HTTPClient()
    payload = {
    message = Command,
    sender = SenderKey,
    ttl=0,
    communication_base_params =
    {
    type = 'Message',
    fallback = false,
    via = 'Wifi'
    },
    version = '1.63'
    }

    http:request('http:' .. receiverIP .. ':' .. AutoRemotePort,
    {
    options = payload,
    success = successCallback,
    error = errorCallback
    }
    )
    end

    -- Do the request
    getDirect(targetIP, targetPort, targetKey, 'the_command')

    -------------------------------------------------------------------------------
     
    Last edited: Apr 20, 2016
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Just to clarify: your issue is that in 1 the request worked but the message didn't show up in the logs? Can you please post the url you used for the request? thanks
     
  3. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    Ok, at least I got the communication functioning.
    The url is '192.168.178.43:1817'
    But there are several other Problems
    1. there is no way to see that the AutoRemote WiFi service is running or not
    2. the WiFi service is shutting down without any reason, after a new start all is ok
    3. sometimes Tasker did not get the AutoRemote Trigger, stop/start the WiFi service solve it sometimes
    4. why must the WiFi Service to be started with Tasker-Task. It should be enabled in AutoRemote Settings and
    there should be a indicator that it is running.
    Hope that helps.

    thanks
     
  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    When you started the service, did you enable the "Persistent Notification" option? That should probably fix some of those issues.
     
  5. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    thx for the hint.
    Is there a way to figure out that the service is running?
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Yes, enable the option I mentioned and check your notification tray :)
     
    okatzer likes this.
  7. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    hey, I think the AutoRemote WiFi service is running stable now
    But I figured out some other problems.
    Sometimes it seams that Tasker did not get all the triggers.
    The toast message comes up and a log entry is generated by AutoRemote.
    I have three triggers with "exact Message Filter" and three task to be executed.
    First message works as it should. The next message, the same or an other did not work.
    After a while the next message is ok, and so on.
    But I don't see any regularity.
    Is there a delay before the next trigger can be done?
    Sometimes Tasker did not do anything.

    thx for your support
     
  8. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    There shouldn't be a delay.
    Can you please export your profile's description (not xml) so I can take a look? Long-click the profile in Tasker->export description Thanks in advance
     
  9. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    Profil: TürAchtung (22)
    Ereignis: AutoRemote [ Konfiguration:TürAchtung (exact) ]
    Eingang: Tür Achtung (23)
    A1: Sende Intent [ Aktion:darker.PAUSE Typ:None MIME Typ: Daten: Extra: Extra: Extra: Paket: Klasse: Ziel:Broadcast Receiver ]
    A2: Szene Anzeigen [ Name:TürAchtung Anzeigen Als:Dialog Horizontale Position:100 Vertikale Position:100 Animation:System Exittaste Anzeigen:An sofort mit Task fortfahren:An ]
    A3: Beep [ Frequenz:8000 Dauer:1000 Amplitude:50 Stream:3 ]

    Profil: TürZu (27)
    Ereignis: AutoRemote [ Konfiguration:TürZu (exact) ]
    Eingang: Tür Zu (26)
    A1: Szene Zerstören [ Name:TürAchtung ]
    A2: Szene Zerstören [ Name:TürOffen ]
    A3: Sende Intent [ Aktion:darker.PAUSE Typ:None MIME Typ: Daten: Extra: Extra: Extra: Paket: Klasse: Ziel:Broadcast Receiver ]
    A4: Beep [ Frequenz:8000 Dauer:1000 Amplitude:50 Stream:3 ]

    Profil: TürOffen (28)
    Ereignis: AutoRemote [ Konfiguration:TürOffen (exact) ]
    Eingang: Tür Offen (24)
    A1: Szene Zerstören [ Name:TürAchtung ]
    A2: Szene Anzeigen [ Name:TürOffen Anzeigen Als:Dialog Horizontale Position:100 Vertikale Position:100 Animation:System Exittaste Anzeigen:An sofort mit Task fortfahren:An ]
    A3: Beep [ Frequenz:8000 Dauer:1000 Amplitude:50 Stream:3 ]
     
  10. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Can you please enter each task and click the settings icon and change "Collision Handling" top "Run Both Together" then try again? thanks
     
  11. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    Hey, sorry I can't find the settings icon . Is it visible when editing the task?
    can you show a screenshot
     
  12. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Check here.
     

    Attached Files:

  13. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    OK, found it. I was on beginner mode.
    I played around with messages over GCM and it seams to be OK.
    I'm at work an can't test with WiFi Service. I will try later an give you feedback

    thanks for support
     
  14. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
  15. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    hey, I'am back again with some information.
    The communication with the AutoRemote WiFi Service works at 90% of the time.
    But sometimes there is a org.json.JSONException.
    After that the WiFi Service did not recognize any message.
    I upload the json exception as a file, hope that helps.
    thx
     

    Attached Files:

    • com.txt
      File size:
      928 bytes
      Views:
      2
  16. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Can you tell what the content of the request was when that happened? Thanks
     
  17. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    This is Code I use:
    (Fibaro HomeCenter 2 - LUA Code )

    local function sendLocal(receiverIP, AutoRemotePort, SenderKey, Command)
    local httpClient = Tk.Net.HttpRequest(receiverIP,AutoRemotePort)

    payload = {
    message = Command,
    sender = SenderKey,
    ttl=0,
    communication_base_params =
    {
    type = 'Message',
    fallback = false,
    via = 'Wifi'
    },
    version = '1.63'
    }
    local strPayload = json.encode(payload)

    local response, status, errorCode = httpClient:request('POST', '', {}, strPayload)
    end

    -- first call the function
    sendLocal('192.168.178.32', '1817', 'Fibaro_HC2', 'TürAchtung')
    -- second call
    sendLocal('192.168.178.32', '1817', 'Fibaro_HC2', 'TürOffen')
    -- third call
    sendLocal('192.168.178.32', '1817', 'Fibaro_HC2', 'TürZu')

    Thees three calls where send with different time-laps between them.
    Very often everything works fine and sometimes there comes the exception.
    Hope that helps.
     
  18. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Does it maybe happen if you call them all very fast? Can you please try putting a small wait in between them and check if that makes a difference? Thanks!
     
  19. okatzer

    okatzer New Member

    Joined:
    Apr 17, 2016
    Messages:
    12
    Likes Received:
    0
    Sorry for the long time not answering.
    The problem with the "org.json.JSONException" ist still there.
    I think it is not a problem with fast calls.
    Maybe you can change the exception handling in the service, so that the service is still running after an exception.
    In the moment the service stoped if an exception appears, but the notification says the service is still running.
    It is a real pity, but in this way the whole system ist not useful for me.
    I can not check every hour if the service is running.

    I hope we will get an solution soon .
    Thanks!
     
: http, request, Fibaro

Share This Page