66 657 läst · 113 svar
67k läst
113 svar
Worx Landroid development
Mattias: Is your version working with HASS running https? I changed to https and password recently and now your script wont connect:Mattias Jiderhamn skrev:
Error calling Home Assistant: {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}
miktr skrev:
Sounds good, I got stuck immediately though
I git-cloned your repository and modified config.ini.
Do I need to change anything else in worx-landroid-mqtt.py?
Is this the startup py btw?
Scripts stops at import requests with error missing module.
Also, I use cert together with my mqtt, can I specify that somewhere?
Example of pub I use today;
mosquitto_pub --cafile /home/pi/ca.crt -h 192.168.1.111 -p 8883
I don't use OpenHab or Dweet, I just need to publish the values to mqtt so I can fetch them with Home Assistant
Thanks!
Hi,
I pushed a new commit with a new name of the main script, now "run.py" instead of "worx-landroid-mqtt.py".
I also added some instructions to READEME.md.
* Dweet is removed
* Install the module "requests" (pip install requests)
* To run "python run.py"
To test with mosquitto_pub.exe:
$ ./mosquitto_pub.exe -h 192.168.1.5 -t my_topic/command -m check
I pushed a new commit with a new name of the main script, now "run.py" instead of "worx-landroid-mqtt.py".
I also added some instructions to READEME.md.
* Dweet is removed
* Install the module "requests" (pip install requests)
* To run "python run.py"
To test with mosquitto_pub.exe:
$ ./mosquitto_pub.exe -h 192.168.1.5 -t my_topic/command -m check
miktr skrev:Hi,
I pushed a new commit with a new name of the main script, now "run.py" instead of "worx-landroid-mqtt.py".
I also added some instructions to READEME.md.
* Dweet is removed
* Install the module "requests" (pip install requests)
* To run "python run.py"
To test with mosquitto_pub.exe:
$ ./mosquitto_pub.exe -h 192.168.1.5 -t my_topic/command -m check
Thank you miktr
I did a new clone, updated config.ini, installed requests and ran python run.py
Sadly I get:
[Errno 104] Connection reset by peer
I can access the W796E using a browser and same url as defined in config.
Config:
Tested to publish to my broker and that is working (no data though for obvious reason).{"CntProg":404,"lingua":0,"ore_funz":[192,195,195,195,192,195,192],"ora_on":[9,9,9,9,9,9,9],"min_on":[0,0,0,0,0,0,0],"allarmi":[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"settaggi":[0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"mac":[0,35,167,72,146,130],"time_format":1,"date_format":0,"rit_pioggia":60,"area":0,"enab_bordo":0,"g_sett_attuale":0,"g_ultimo_bordo":0,"ore_movimento":8678,"percent_programmatore":0,"indice_area":9,"tipo_lando":8,"beep_hi_low":0,"gradi_ini_diritto":30,"perc_cor_diritto":103,"coef_angolo_retta":80,"scost_zero_retta":1,"offset_inclinometri":[2072,2035,2688],"gr_rall_inizio":80,"gr_rall_finale":300,"gr_ini_frenatura":130,"perc_vel_ini_frenatura":50,"tempo_frenatura":20,"perc_rallenta_max":50,"canale":0,"num_ricariche_batt":5,"num_aree_lavoro":3,"Dist_area":[10,70,55,1],"perc_per_area":[2,2,6,1],"area_in_lavoro":6,"email":"XXXXXXXXxxxxxxx.com","perc_batt":"58"}
Running script as root if that matters (installation on a rPi)
Redigerat av moderator:
Jocke, did you need do modify anything to get the script to connect to the Landroid (except for ip and pin ofc)?Jocke-g skrev:Really nice, I did get it to work.
I had to install python-pip first, and git-core to clone the files, but then it worked.
I do have some suggestions on improvements though.
- One topic where you send out current status, as text string. Either current alarm, or Mowing/Charging/Seeking charger.
- Send out messaegs by interval, without need to receive the check command. Say each minute, and add setting in config file to define this.
- MQTT authentication
I still can't connect to the mower but ping works fine from same server.
I also get json response when using browser
I was using 2.7, now I tried with python3 and got another errormiktr skrev:
Maybe I need paho installed anyhow. I'll test some more.
miktr skrev:
Ok, I did some more testing this evening.
I cloned your repository to the same rPi running the broker.
This way I could use localhost and 1883 for connection.
When running python3 run.py I now get " Connected with result code0" which I assume is good?
So the connection error was not to the landroid but to the broker.
Anyway. when running;
"mosquitto_pub -h localhost -t my_topic/command -m check" in another window I can see that it is publishing to my broker, however I do not get any landroid stats (which I expected). So It seems that run.py doesn't read the message sent?
I would prefer to run this on another rPi but it seems that it have issues when you need username/password or cert?
Thanks
Redigerat:
Fredrik Levin;2555979]Ok, I did some more testing this evening.
I cloned your repository to the same rPi running the broker.
This way I could use localhost and 1883 for connection.
When running python3 run.py I now get " Connected with result code0" which I assume is good?
So the connection error was not to the landroid but to the broker.
Anyway. when running;
"mosquitto_pub -h localhost -t my_topic/command -m check" in another window I can see that it is publishing to my broker, however I do not get any landroid stats (which I expected). So It seems that run.py doesn't read the message sent?
Wild shot since Im no python programmer but arent you missing a ) when using # here?
https://github.com/trieb/worx-landroid/blob/master/run.py#L24
I would prefer to run this on another rPi but it seems that it have issues when you need username/password or cert?
EDIT: reading further I might need to set mqttc.tls_set with my cert path.
Ill test more tomorrow
Thanks
I cloned your repository to the same rPi running the broker.
This way I could use localhost and 1883 for connection.
When running python3 run.py I now get " Connected with result code0" which I assume is good?
So the connection error was not to the landroid but to the broker.
Anyway. when running;
"mosquitto_pub -h localhost -t my_topic/command -m check" in another window I can see that it is publishing to my broker, however I do not get any landroid stats (which I expected). So It seems that run.py doesn't read the message sent?
Wild shot since Im no python programmer but arent you missing a ) when using # here?
https://github.com/trieb/worx-landroid/blob/master/run.py#L24
I would prefer to run this on another rPi but it seems that it have issues when you need username/password or cert?
EDIT: reading further I might need to set mqttc.tls_set with my cert path.
Ill test more tomorrow
Thanks
Redigerat:
Hi,
I assume run.py is started with:
$python run.py
>> Connected with result code0
then, running the following in another terminal
$ ./mosquitto_pub.exe -h localhost -t my_topic/command -m check
should result in:
$ python run.py
>> Connected with result code0
>> Received new message
>> my_topic/command: b'check'
>> Sending check...
Where the last three rows indicate that run.py received the message ok, and that a status request was sent to the landroid.
Just to make sure, in the example above the "BaseTopic" in config.ini is assumed to be set to my_topic.
I can add some more debugging info to the script later tonight to help find out whats going wrong. Line 24 should however be ok as is is.
I assume run.py is started with:
$python run.py
>> Connected with result code0
then, running the following in another terminal
$ ./mosquitto_pub.exe -h localhost -t my_topic/command -m check
should result in:
$ python run.py
>> Connected with result code0
>> Received new message
>> my_topic/command: b'check'
>> Sending check...
Where the last three rows indicate that run.py received the message ok, and that a status request was sent to the landroid.
Just to make sure, in the example above the "BaseTopic" in config.ini is assumed to be set to my_topic.
I can add some more debugging info to the script later tonight to help find out whats going wrong. Line 24 should however be ok as is is.
miktr skrev:Hi,
I assume run.py is started with:
$python run.py
>> Connected with result code0
then, running the following in another terminal
$ ./mosquitto_pub.exe -h localhost -t my_topic/command -m check
should result in:
$ python run.py
>> Connected with result code0
>> Received new message
>> my_topic/command: b'check'
>> Sending check...
Where the last three rows indicate that run.py received the message ok, and that a status request was sent to the landroid.
Just to make sure, in the example above the "BaseTopic" in config.ini is assumed to be set to my_topic.
I can add some more debugging info to the script later tonight to help find out whats going wrong. Line 24 should however be ok as is is.
Hi, yes that's the way I did it.
Basic topic is unchanged.
I ended up starting to build a modified version so no need to dig deeper if you don't want to.
I will use your code for communication to the landroid but instead of subscribing to the broker I will publish the messages directly by replacing your push_message (mqttc.publish) with my mosquitto code.
I can then just put this in cron for scheduled updates.
Not as fancy but it is working.
Thanks for your help and effort.
Hi!
Does anyone know how I can send a "Start"-command to my Landroid without using Json?
I've tried this in C#:
private void button1_Click(object sender, EventArgs e)
{
string url = "http://192.168.0.3/jsondata.cgi";
string username = "admin";
string password = "0000";
string postData = @"data=[""settaggi\11,1""]";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
request.Headers.Add("Authorization", "Basic " + encoded);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
textBoxReadings.Text = (((HttpWebResponse)response).StatusDescription) + Environment.NewLine;
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
textBoxReadings.Text = textBoxReadings.Text + (responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
}
Does anyone know how I can send a "Start"-command to my Landroid without using Json?
I've tried this in C#:
private void button1_Click(object sender, EventArgs e)
{
string url = "http://192.168.0.3/jsondata.cgi";
string username = "admin";
string password = "0000";
string postData = @"data=[""settaggi\11,1""]";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
request.Headers.Add("Authorization", "Basic " + encoded);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
textBoxReadings.Text = (((HttpWebResponse)response).StatusDescription) + Environment.NewLine;
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
textBoxReadings.Text = textBoxReadings.Text + (responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
}