I’m getting an LG Washer in just over a week, happy to help with testing! Previously I had an old Bosch which I’d added an old Cellphone Charger to the door catch fed into a Tasmota equipped ESP so I could detect when it unlocked the door at the end of the cycle, together with a relay contact behind the start button to start it remotely. Hopefully I can at least get this functionality working without resorting to the soldering iron
haha the things we do for home automation…i used a pow and a vibration sensor to know if my washer is done…Now i own a ThinQ washer and a dryer,i use the android app to send me notifications and with tasker i send a command to my openhab when the cycle is done.
Nice work! Do you want discussions about this work on GiT or on here? Once I get my Washer I would like to use:
washing started and washing ended notifications
I’d like to initiate
remote start and ideally set the finish time as it looks like this may be lost after every cycle.
Could JSON parsing be done using a thing? I’ve managed to do that with some of my stuff but not all.
Lets continue here since we already have a thread. JSON can be parsed in things using JSONPATH and Transformation Patterns and we have the flexibility of deciding the JSON structure. You can store the start and end times using persistence in OH.
Remote start is possible , but I 'vent got around to exploring that yet.
Seems like I am already on protocol version 2. I managed to get it running with this one:
I modified the script to connect to my mosquitto mqtt broker, sending all changes in realtime there - so basically the same mechanism you use I guess?
In order to avoid the JSON-parsing in OH, I decided to transform the JSON-string from the LG API into a python dictionary and then publish all keys/values to mqtt… This way all values are there and the user can decide which channels he wants to use…
nicely done! i just want to set up a notification when my washer and my dryer cycle is done(both LG ThinQ).Can you please guide me how to set up the script to connect to my mqtt broker?
Still not working…
Could it be the version of Python?
[20:54:03] openhabian@openHABianPi:~/lq/wideq-master/wideq-master$ python3 example.py -c SG -l en-SG ls
File “example.py”, line 258
help=f’one of: {", ".join(EXAMPLE_COMMANDS)}’)
^
SyntaxError: invalid syntax
Neat…ya , this is exactly the same way I’m doing . My MQTT looks something like this. Ive to parse the values and make it a bit more userfriendly
Latest code is on my wideq fork
Sorry I’ve no clue…maybe you can clone my code and see if that works . My example.py works only for washers
My latest code will output MQTT in the following format
{‘State’: ‘Rinsing’, ‘Remain_Time_H’: ‘0’, ‘Remain_Time_M’: ‘2’, ‘Initial_Time_H’: ‘1’, ‘Initial_Time_M’: ‘14’, ‘Course’: ‘15’, ‘Error’: ‘0’, ‘Soil’: ‘Normal’, ‘SpinSpeed’: ‘No Spin’, ‘WaterTemp’: ‘-’, ‘RinseOption’: ‘Normal’, ‘DryLevel’: ‘-’, ‘Reserve_Time_H’: ‘0’, ‘Reserve_Time_M’: ‘0’, ‘Option1’: ‘0’, ‘Option2’: ‘128’, ‘Option3’: ‘0’, ‘PreState’: ‘Running’, ‘SmartCourse’: ‘0’, ‘TCLCount’: ‘35’, ‘LoadItem’: ‘0’, ‘CourseType’: ‘0’, ‘Standby’: ‘@Cp Off En’}
You can use JSONPATH in OH and straightaway display the status
trying to run your script ,when i paste the browser link after login i get this:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 453, in wrap_socket
cnx.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1647, in _raise_ssl_error
_raise_current_error()
File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 841, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 344, in connect
ssl_context=context)
File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 344, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 459, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])",)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
[Previous line repeated 2 more times]
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='aic.lgthinq.com', port=46030): Max retries exceeded with url: /api/member/login (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])")))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "example.py", line 245, in <module>
main()
File "example.py", line 241, in main
example(args.country, args.language, args.verbose, args.cmd, args.args)
File "example.py", line 183, in example
example_command(client, cmd, args)
File "example.py", line 152, in example_command
func(client, *args)
File "example.py", line 49, in ls
for device in client.devices:
File "/home/pi/wideq/wideq/client.py", line 126, in devices
self._devices = self.session.get_devices()
File "/home/pi/wideq/wideq/client.py", line 117, in session
self._session, self._devices = self.auth.start_session()
File "/home/pi/wideq/wideq/core.py", line 362, in start_session
self.gateway.country, self.gateway.language)
File "/home/pi/wideq/wideq/core.py", line 258, in login
return lgedm_post(url, data)
File "/home/pi/wideq/wideq/core.py", line 202, in lgedm_post
res = session.post(url, json={DATA_ROOT: data}, headers=headers)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='aic.lgthinq.com', port=46030): Max retries exceeded with url: /api/member/login (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl_choose_client_version', 'unsupported protocol')])")))
Please have a look at the issue reported here
tried to login with US language which is the right one for my case ,tried to login without language code and got the same error all the time.Anyway i gave up ,i am a linux noobie anyway.I will wait till any of you code experts come up with a script or even a binding for LG ThinQ…My washer and my dryer are always available for testing,thnx.
Just tried to run the example and once I’d done the URL cut and paste it returned to the command prompt.
python3 example.py ls
returns nothing
python3 example.py mon
returns
Traceback (most recent call last):
File "example.py", line 245, in <module>
main()
File "example.py", line 241, in main
example(args.country, args.language, args.verbose, args.cmd, args.args)
File "example.py", line 183, in example
example_command(client, cmd, args)
File "example.py", line 152, in example_command
func(client, *args)
TypeError: mon() missing 1 required positional argument: 'device_id'
Thats for an account created a week ago and a machine registered today, The app works.
you have to put your ‘device_id’ after ‘mon’ command.I run the script and i get my washer and my dryer ids but when i try to monitor one of them i get nothing too.
I’m guessing as ‘ls’ gave an empty reply that I’m on the V2 system so this won’t work? I tried the other script above and it keeps meaning about a missing marshmallow and trying to install it gives a can’t find a suitable version error
I am running on V2 but “ls” worked fine, instead “mon” never worked for me with wideq
my devices r brand new,one week old and so my LG account.I am guessing that i am v2 too.I used this WideQ cause i could not manage to install Arun’s or tinkerborg’s code (i am a linux noobie) and using ls i get to see my devices id’s just fine,‘mon’ command is not working.
if ‘mon’ is not working for you ,how did u manage to send state changes to ur mqtt broker?Can u share your script and guide my how to do that too please?
Well that’s the point, I moved from wideq to thinq2-python - and here everything works… For this you need to install poetry first:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
As poetry is still calling “python” by default, you would need to edit the first line of the poetry script:
vi $HOME/.poetry/bin/poetry
and change this line:
#!/usr/bin/env python
to
#!/usr/bin/env python3
Now as poetry is working, you can go ahead with the thinq2-python:
# Load the poetry environment
source $HOME/.poetry/env
cd /etc/openhab2/scripts
git clone https://github.com/tinkerborg/thinq2-python.git
cd thinq2-python
poetry install
For the very first start of thinq2-mqtt you need to run:
COUNTRY_CODE=US LANGUAGE_CODE=en-US poetry run python3 example.py
For any further run you can simply call:
poetry run python3 example.py
PS: Maybe you didn’t see my PM last time?