Gardena mower control (domoticz-mqtt2-gardena)

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.

Moderator: leecollings

marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Gardena mower control (domoticz-mqtt2-gardena)

Post by marmachine »

I wanted to integrate my Gardena smart mower, so i've found and setup some stuff, following the below link.

https://github.com/Kdonkers/domoticz-mq ... control.py

After install/setup, i run the above Python script and get an error regarding missing websockets... (python3 gardena.py)

That is where i ended up, because when i try to install the (assumed missing) package, that also runs into an error. (sudo pip install websocket)

This is about how far my knowledge of RPI goes, so if anyone has some advice or direction, that'll be great!
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by FireWizard »

Hi, @marmachine

Did you install websockets?

If not, can you try

Code: Select all

sudo pip3 install websocket
and

Code: Select all

sudo pip3 install websocket-client

For your information:

pip is used in case of Python 2, but as you have Python 3, you should use pip3.

Try it and let us know.

Regards
marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by marmachine »

FireWizard wrote: Monday 28 June 2021 18:56 pip is used in case of Python 2, but as you have Python 3, you should use pip3.
Successfully installed gevent-21.1.2 greenlet-1.1.0 websocket-0.2.1 zope.event-4.5.0 zope.interface-5.4.0

Successfully installed websocket-client-1.1.0

That worked! :D thanks man!
marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by marmachine »

Dependencies are now solved, or so it seems...

Now when running the script: python3 gardena.py
Logging into authentication system...
Logged in (token_data_here), getting WebSocket ID...
WebSocket ID obtained, connecting...

...

...

Nothing happens!? It seems to be in a never ending loop...
Is it connected? Where should it connect to? Should i change any of the defaults?
Which variables should i check?
No info, I'm lost...
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by FireWizard »

Hi, @marmachine

I see that you have also opened two issues at: https://github.com/Kdonkers/domoticz-mq ... ena/issues

It's not good idea to request support in multiple places.
Github is for issues with the application.
As far as I can see there are no issues with the application, except that you miss some information, but remember, if you feel the README file is missing essential information, please add it and make a PR. That will help the community.

You said:
Nothing happens!? It seems to be in a never ending loop...
Is it connected? Where should it connect to? Should i change any of the defaults?
Which variables should i check?
No info, I'm lost...
Let's check some steps:

1. Did you create the 3 Dummy devices in Domoticz?
Create 3 dummy devices in Domoticz:

Battery: Percentage (DOMOTICZ_MOWER_RFLINK_IDX)
Status: Text (DOMOTICZ_MOWER_STATUS_IDX)
Connectivity: Percentage (DOMOTICZ_MOWER_RFLINK_IDX)
Note down the IDX numbers!

2. Did you install Mosquitto? (Or any other broker)

If so, what is its IP Address? (localhost? or 127.0.0.1?)

3. Did you edit the file gardena.py?
Line 10, 11, 12?
Line 20, 21, 22?
And maybe 23 and 24?

On Github I saw you installed:

Code: Select all

sudo pip3 install paho-mqtt.
Let me know.

On Github you wrote:
Where should it connect to? Which variables should i check? I'm lost...
It should connect to your MQTT server. (Mosquitto).
Check if the dummy devices receive the correct values >> NOTHING
if not, make sure your variables are all set correctly. >> WHICH VARIABLES?
See above under 3.

So

Line 11, 12 and 13 is information you should have got from Gardena/Husqvarna.

Leave line 19 unchanged.
Change the number after "DOMOTICZ_MOWER_STATUS_IDX =" with your IDX number.
Same for line 21 and 22.

If your MQTT server (broker) has been installed on another device than Domoticz, change line 23 with the correct IP Address
Same with line 24, if you did change the default MQTT port (default 1883).

Let me know the results.

Regards
marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by marmachine »

FireWizard wrote: Monday 28 June 2021 22:19 1. Did you create the 3 Dummy devices in Domoticz?
2. Did you install Mosquitto? (Or any other broker) If so, what is its IP Address? (localhost? or 127.0.0.1?)
3. Did you edit the file gardena.py?

If your MQTT server (broker) has been installed on another device than Domoticz, change line 23 with the correct IP Address
Same with line 24, if you did change the default MQTT port (default 1883).
Yes, all checked
Mosquito is indeed on the same device, however entering it's IP wouldn't harm either i guess, port is correct
I've created a check on Node-red to see if something pop's up in debug when published to topic domoticz/in and payload contains one of the IDX's

Code: Select all

import websocket
from threading import Thread
import time
import sys
import requests
import json
import paho.mqtt.client as mqtt

# account specific values
USERNAME = 'my user account' # 'USERNAME_GARDENA'
PASSWORD = 'my password' # 'PASSWORD_GARDENA'
API_KEY = 'my api key' # 'API_KEY_GARDENA'

# other constants
AUTHENTICATION_HOST = 'https://api.authentication.husqvarnagroup.dev'
SMART_HOST = 'https://api.smart.gardena.dev'

#MQTT
DOMOTICZ_TOPIC = 'domoticz/in'
DOMOTICZ_MOWER_STATUS_IDX = 284   # STATUS IDX DOMOTICZ
DOMOTICZ_MOWER_BATTERY_IDX = 283  # BATTERY IDX DOMOTICZ
DOMOTICZ_MOWER_RFLINK_IDX = 285   # CONNECTIVITY IDX DOMOTICZ
DOMOTICZ_MQTT = '192.168.mosquito_ip_address'
DOMOTICZ_MQTT_PORT = 1883
FireWizard wrote: Monday 28 June 2021 22:19 I see that you have also opened two issues at: https://github.com/Kdonkers/domoticz-mq ... ena/issues

It's not good idea to request support in multiple places.
Github is for issues with the application.
As far as I can see there are no issues with the application, except that you miss some information, but remember, if you feel the README file is missing essential information, please add it and make a PR. That will help the community.
I'll look into the PR, was unfamiliar with that functionality.

On the application;
In the code there is an # websocket.enableTrace(true), after removing the # i get the results of both the request and result.
This indicates that there is data returned from the websocket, so there is a successfull connection.
The Data seems to be the correct data, however it is not showing up in Node-red or Domoticz (i already had Mosquito running)

My conclusion for now is that the returned data is in an unexpected format, this results in an error (multiple errors) and it's not published to MQTT so doesn't appear in Domoticz.

Possible cause remains to be investigated:
- Something has changed on the 'other side' where the data is obtained
- I might have a different version of websocket (?)
- Publishing to MQTT is unsuccessfull for some reason

Anyhow, i think that all the above could be improvements for the application, at least by returning some indication of error(s).

Still i am lost... i update the issues with results and investigations continuously, for now this seems the best place to keep track of things and could help the community as well...

However, thanks for your response!
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by FireWizard »

Hi, @marmachine

You wrote:
Mosquito is indeed on the same device, however entering it's IP wouldn't harm either i guess, port is correct
No, using the IP Address should not have any effect. However the IP address is numerical, separated by dots. I do not think this should between ' '.
You can try to insert 'localhost' or to insert the IP Address without ' '.
I've created a check on Node-red to see if something pop's up in debug when published to topic domoticz/in and payload contains one of the IDX's
A very easy tool is also: http://mqtt-explorer.com/
In the code there is an # websocket.enableTrace(true), after removing the # i get the results of both the request and result.
This indicates that there is data returned from the websocket, so there is a successfull connection.
Agree, this means you receive data from https://api.smart.gardena.dev
My conclusion for now is that the returned data is in an unexpected format, this results in an error (multiple errors) and it's not published to MQTT so doesn't appear in Domoticz.
Check with 'localhost' first. I agree, it is not publishing to domoticz/in and so it will not appear in Domoticz.

Let me know.

Regards
marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by marmachine »

FireWizard wrote: Tuesday 29 June 2021 11:59
using the IP Address should not have any effect. However the IP address is numerical, separated by dots. I do not think this should between ' '.
You can try to insert 'localhost' or to insert the IP Address without ' '.

Check with 'localhost' first. I agree, it is not publishing to domoticz/in and so it will not appear in Domoticz.

Let me know.

Regards
The IP address in config without the ' ' around it, results in an error, it is not a valid nummeric value.
The result with 'localhost' is similar to the previous test with the IP between quotes, like: '192.168.1.199'
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by FireWizard »

Hi, @marmachine,
The IP address in config without the ' ' around it, results in an error, it is not a valid nummeric value.
The result with 'localhost' is similar to the previous test with the IP between quotes, like: '192.168.1.199'
It is pity, that that didn't work either. I'm afraid I cannot support you any further, as I do not own a Gardena mower and so do not have a Gardena/Husqvarna account.

One thing came up lately. You did not secure your Mosquitto broker with a username/password, didn't you?

You tried with the command

Code: Select all

python3 gardena.py
? Otherwise try with sudo.

But perhaps the author will respond on Github.

Regards
User avatar
FireWizard
Posts: 1895
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by FireWizard »

Hi,

Just an afterburner:

Did you see: https://github.com/py-smart-gardena/py-smart-gardena

Perhaps you can try that.

Also some discussion at the Node Red forum: https://discourse.nodered.org/t/websock ... on/42177/5

Regards
Last edited by FireWizard on Wednesday 30 June 2021 14:46, edited 1 time in total.
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by waltervl »

And check also this topic. Python code seems to be almost similar.....

https://domoticz.com/forum/viewtopic.php?f=56&t=23538
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
marmachine
Posts: 133
Joined: Saturday 26 March 2016 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by marmachine »

Tried to run it as Sudo as well, same result.
I'm also aware of the Mosquito security patch, but have that disabled (because didn't want to reconfigure all my Shelly's in the house)
However, the MQTT broker security isn't included in the script, is it? I don't recall any settings for it.

Looking at the error, it still leaves me with my conclusion that, possibly somewhere over time, the response data or it's structure has changed or/and it now is incompatible with my websocket version.

Code: Select all

...callback <bound method Client.on_open of <__main__.Client object at 0x759aff50>>: on_open() takes 1 positional argument but 2 were given
  File "/usr/local/lib/python3.7/dist-packages/websocket/_app.py", line 407, in _callback...
Anway, you leave me some topics and threads to study or investigate, thanks for that and all your effort as well!
Much appreciated!
thomasbaetge
Posts: 153
Joined: Wednesday 02 October 2019 11:47
Target OS: Linux
Domoticz version: 2023.1
Location: DE / BY / LT
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by thomasbaetge »

Sorry....I may be a bit late to the party...but since the last piece of code referred to was done by me:
I had that running the whole season until recently without any issues in controlling my mower.
So if you still need assistance, feel free to ask.
daniele
Posts: 1
Joined: Saturday 10 September 2022 14:12
Target OS: -
Domoticz version:
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by daniele »

thomasbaetge wrote: Tuesday 14 December 2021 11:11 Sorry....I may be a bit late to the party...but since the last piece of code referred to was done by me:
I had that running the whole season until recently without any issues in controlling my mower.
So if you still need assistance, feel free to ask.
Hello,
I have just found this interesting software. Can you please advise if it does work even if the mower is not equipped with the additional control board?

Then I have not understood how the raspberry can be Bluetooth paried with the mower.

Thanks for helping,
Daniele
thomasbaetge
Posts: 153
Joined: Wednesday 02 October 2019 11:47
Target OS: Linux
Domoticz version: 2023.1
Location: DE / BY / LT
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by thomasbaetge »

Hi Daniele,

sure it does, as long as your Gardena mower comes with the Gateway and the app.
I don't have this additional board either, I find it rather useless.
arjan93
Posts: 25
Joined: Friday 16 November 2018 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by arjan93 »

Hii,

I have some troubles with the gardena.py script. I have changed the variables to my own idx etc but
when I run the script it gives a error:
Logging into authentication system...
Traceback (most recent call last):
File "/home/pi/domoticz/plugins/domoticz-mqtt2-gardena/gardena.py", line 72, in <module>
assert r.status_code == 200, r
AssertionError: <Response [400]>
I've been struggling with this problem for a few days now, but I can`t get it work.

Can someone help me with this error?
arjan93
Posts: 25
Joined: Friday 16 November 2018 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by arjan93 »

arjan93 wrote: Monday 24 October 2022 18:47 Hii,

I have some troubles with the gardena.py script. I have changed the variables to my own idx etc but
when I run the script it gives a error:
Logging into authentication system...
Traceback (most recent call last):
File "/home/pi/domoticz/plugins/domoticz-mqtt2-gardena/gardena.py", line 72, in <module>
assert r.status_code == 200, r
AssertionError: <Response [400]>
I've been struggling with this problem for a few days now, but I can`t get it work.

Can someone help me with this error?
I`m still struggling with this error.. any ideas?
User avatar
waltervl
Posts: 5859
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by waltervl »

Did you modify gardena.py according this issue https://github.com/Kdonkers/domoticz-mq ... a/issues/4
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
thomasbaetge
Posts: 153
Joined: Wednesday 02 October 2019 11:47
Target OS: Linux
Domoticz version: 2023.1
Location: DE / BY / LT
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by thomasbaetge »

It's mower season again :)

The error above came from too many requests, i.e. your application key has been blocked.

I've put a new version on Github (MQTT integration) that reflects the current API changes and implements different Websocket handling, so you won't have the issue above anymore.
dakarli
Posts: 5
Joined: Monday 16 March 2020 10:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Gardena mower control (domoticz-mqtt2-gardena)

Post by dakarli »

*** EDITED ***

Hi Guys,

I'm was also fighting with the same issue as @arjan93

After a few trys i decided to fork the original repository on github and made some changes. It is now working fine for me.

You can find the fork here:
https://github.com/DaKarlii/gardena-2-mqtt-domoticz

Please PM me or use Github if you find any further issues in the script - i will try to fix as fast as possible (if im able to)

Main Changes:
  • Update to current Login Method (API-Key & Secret)
  • Outsourced the variables to a seperate *.cfg file


Br
Karli
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest