domochip / gardena2mqtt Goto Github PK
View Code? Open in Web Editor NEWGateway to control GARDENA Smart system devices through MQTT
License: GNU General Public License v3.0
Gateway to control GARDENA Smart system devices through MQTT
License: GNU General Public License v3.0
When trying to start the docker instance I get the following error:
07:59:13: ===== Connection To MQTT Broker =====
Traceback (most recent call last):
File "/app/gardena2mqtt.py", line 226, in
mqttclient.connect(mqtthost, mqttport)
File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 939, in connect
self.connect_async(host, port, keepalive,
File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1006, in connect_async
if port <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'
The credentials are correct as well as the hostname of the MQTT-server.
I'm getting an error when trying to connect to the API:
Any ideas on what it could be?
11:26:37: ===== gardena2mqtt v1.0.2 =====
11:26:37: ===== Prepare MQTT Client =====
11:26:37: ===== Prepare SmartSystem Client =====
11:26:37: - create
11:26:37: - authenticate
Traceback (most recent call last):
File "/app/gardena2mqtt.py", line 210, in <module>
smart_system.authenticate()
File "/usr/local/lib/python3.9/site-packages/gardena/smart_system.py", line 115, in authenticate
self.token = self.oauth_session.fetch_token(
File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 360, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 429, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
validate_token_parameters(params)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 432, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 402, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.UnauthorizedClientError: (unauthorized_client) Unauthorized client: `grant_type` is invalid
I am using a compose file to start docker container.
Compose file here on github is:
version: '3'
services:
gardena2mqtt:
container_name: gardena2mqtt
image: domochip/gardena2mqtt
devices:
- /dev/serial/by-id/usb-HUAWEI_HUAWEI_Mobile-if00-port0:/dev/mobile
environment:
- GARDENA_USER=GardenaUserName
- GARDENA_PASSWORD=GardenaPassword
- GARDENA_APIKEY=GardenaApiKey
- HOST=192.168.1.x
- PORT=1883
- PREFIX=gardena2mqtt
- CLIENTID=gardena2mqttclid
- USER=mqtt_username
- PASSWORD=mqtt_password
restart: always
Questions on that:
If I try to start a docker container with the above compose file (without device information) and I got the following log response:
13:17:09: ===== gardena2mqtt v1.0.2 =====
13:17:09: ===== Prepare MQTT Client =====
13:17:09: ===== Prepare SmartSystem Client =====
13:17:09: - create
13:17:09: - authenticate
Traceback (most recent call last):
File "/app/gardena2mqtt.py", line 210, in <module>
smart_system.authenticate()
File "/usr/local/lib/python3.9/site-packages/gardena/smart_system.py", line 115, in authenticate
self.token = self.oauth_session.fetch_token(
File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 360, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 429, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
validate_token_parameters(params)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 432, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 402, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.UnauthorizedClientError: (unauthorized_client) Unauthorized client: `grant_type` is invalid
Without providing the application secret that can not work I guess ...
First of... Great work with this!
I'm a bit new to MQTT and programming overall so I have some questions. How well does this work with Home Assistant and the Mosquitto MQTT broker (https://github.com/home-assistant/addons/tree/master/mosquitto)? Do I need to use any more kind of software other than that?
Hi, excellent job! Easy access via MQTT is really useful.
I had a problem getting the code to work. After a while I found that the location names during the subscription phase were set to "My Garden", while after the first round of device updates (right after setting up MQTT) it changed to "GARDENA smart Garden". Due to the subscription of wrong location names receiving commands did not work.
I guess it's a problem of the Gardena API. A little workaround of moving the "subscribe_everything" call right after "smart_system.start_ws" and a delay of 60 secs solved the problem. Anyone else having the same issue? Or something that needs to be adapted in the code? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.