Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control Husqvarna automower using Automower connect API #4

Open
HansHamran opened this issue Jul 16, 2017 · 1 comment
Open

Control Husqvarna automower using Automower connect API #4

HansHamran opened this issue Jul 16, 2017 · 1 comment

Comments

@HansHamran
Copy link
Owner

HansHamran commented Jul 16, 2017

Chrisz (https://github.com/chrisz/pyhusmow) has created a Pyton script to control the Automower with the unofficial API. Anyone who have tried to use the same API for LUA?

@maglub
Copy link

maglub commented Jul 17, 2018

Since the husmow command (Chrisz application) has a "server" mode, you could probably access it in your own environment quite easily.

From the documentation at https://github.com/chrisz/pyhusmow

So, you start the husmow in server mode on one of your computers at home (my test VM, running Ubuntu 16 LTS, IP address 192.168.4.70):

sudo apt-get install python3 virtualenv jq
virtualenv -p python3 husmow_venv
source husmow_venv/bin/activate
pip3 install pyhusmow
husmow --login MYEMAIL --password MYPASSWORD --log-level INFO --save status

#--- start the server, listening to all IP addresses on the server
husmow server --address 0.0.0.0

Example LUA

local HUSQVARNA = net.HTTPClient();
local url = "http://192.168.4.70:1234/status";

--================================================
-- Start
--================================================

fibaro:debug("#==========================");

local trigger = fibaro:getSourceTrigger()
fibaro:debug("Trigger['type']: " .. trigger['type']);
fibaro:debug("Set up the url: " .. url);

res = HUSQVARNA:request(
  url,{ 
    options = {
      method = "GET", 
    },
    success = function(resp)
      if resp.status == 200 then
        fibaro:debug("It went well: " .. resp.status);
        fibaro:debug(message);
        print(resp.data);
      else
        
        fibaro:debug("REST error: " .. resp.status);
        print (resp.data);
        
      end
    end
    });

fibaro:debug("end");

Screenshot:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants