AutoInput When Controlling Smart things app, Screen capture doesn't work after a forced reboot

Discussion in 'AutoApps' started by David Dimitriou, Oct 12, 2020.

  1. David Dimitriou

    David Dimitriou New Member

    Joined:
    Jul 31, 2019
    Messages:
    6
    Likes Received:
    0
    Hey guys,
    So I'm a Home Assistant user but have had nothing but issues with the Smart Things integration for my home's heat pump system. So I decided to use an old android phone to be dedicated to controlling the Smart Things app using Tasker and Autoinput and Autoremote

    Essentially my Home Assistant sends an Autoremote command to the phone every 10 minutes, which triggers a task that opens the Smart Things app, taps on the different parts of the system (Upstairs Boiler, Downstairs boiler, Hot water etc), and reads the values to get the current state of the heat pump (Hot water on of off, hot water temperature, upstairs heating is on or off, downstairs heating is on or off).

    If these states differ from what Home Assistant wants them to be, then the task will also tap the power buttons of each system to turn on/off the hotwater/heating system.

    The task seems to work very well for a few days, but then it seems to start failing around the point where the screen capture happens. Eventually I get the message 'System UI is not responding'. I'm guessing the memory gets filled up and bogs down the phone. (It's a Nexus 6p that I've rooted if that makes any difference).

    So I'm trying a workaround that just reboots the phone via tasker as soon as Home Assistant notices the values of the heating have not updated for a while. However after this reboot, the task fails immediately when trying to screen capture. It only starts working after I have force closed tasker, autoinput and Smart Things. This is not ideal as I would like it to be completely automated without requiring user input.

    Here's the main task (it's a long one!):
    https://pastebin.com/55aYQVfF

    And here's the task that reads the Home Assistant variables (using the Home Assistant tasker plugin):
    SG Update Heating Status (30)
    A1: Call Service [ Configuration:input_select.select_option Timeout (Seconds):10 ]
    A2: Call Service [ Configuration:input_select.select_option Timeout (Seconds):10 ]
    A3: Call Service [ Configuration:input_select.select_option Timeout (Seconds):10 ]
    A4: Call Service [ Configuration:input_select.select_option Timeout (Seconds):10 ]
    A5: Call Service [ Configuration:input_number.set_value Timeout (Seconds):10 ]

    I'm sure there's a better way to compare the screenshots, but basically on Action 18 of the main task it is taking a screenshot of the power icon of Smart Things (which is blue when its on, and grey when its off) and comparing it with a file that contains the icon when its on.

    Any help much appreciated as this is driving me nuts!
     
  2. David Dimitriou

    David Dimitriou New Member

    Joined:
    Jul 31, 2019
    Messages:
    6
    Likes Received:
    0
    Found a fix. Just added an action before everything begins to tap the home button a couple of times. No idea why it works, but it does. The phone hasn't become unresponsive for more than 3 days now.
     

Share This Page