Miele@home, miele@mobile component

Thanks!

I have now put the following in configuration.yaml:
miele:
client_id: < … >
client_secret: < … >
lang: en

I have tried with both 2 and 4 spaces before client_id, client_secret and lang.

However, still not works. I get the following error message when trying to restart Home Assistant:

r executing service <ServiceCall homeassistant.restart (c:fe6fd31a253d4d3fb2209e47629f4b52)>
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 1117, in _event_to_service_call
await service_handler.func(service_call)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/init.py”, line 175, in async_handle_core_service
errors = yield from conf_util.async_check_ha_config_file(hass)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config.py”, line 793, in async_check_ha_config_file
check_ha_config_file, hass)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/scripts/check_config.py”, line 340, in check_ha_config_file
component = loader.get_component(hass, domain)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py”, line 94, in get_component
module = importlib.import_module(path)
File “/usr/lib/python3.5/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 986, in _gcd_import
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 673, in _load_unlocked
File “”, line 673, in exec_module
File “”, line 222, in _call_with_frames_removed
File “/home/homeassistant/.homeassistant/custom_components/miele/init.py”, line 20, in
from .miele_at_home import MieleClient, MieleOAuth
File “/home/homeassistant/.homeassistant/custom_components/miele/miele_at_home.py”, line 27
_LOGGER.error(f’Failed to retrieve devices: {devices.status_code}’)
^
SyntaxError: invalid syntax

That’s weird. What Python version are you running?

Suspicion: you are running Python 3.5. I just fixed a few incompatibilities, so feel free to pull down the latest version.

You are probably correct. Not fully sure how to check which version, but I have used putty to log on to my terminal and entered python, it seems like I even have version 2.7:
pi@hassbian:~ $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
I will download your new version and test. I will also try to update python to the latest version.

What version of HA are you running? I thought Python 3.5 was the minimum supported version…

Sorry, I had Python 3.5. Now I have upgraded to Python 3.7. However, still does not work. This is from my log file:

2018-09-09 13:25:59 ERROR (SyncWorker_17) [homeassistant.loader] Error loading custom_components.miele. Make sure all dependencies are installed
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/loader.py”, line 94, in get_component
module = importlib.import_module(path)
File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/home/homeassistant/.homeassistant/custom_components/miele/init.py”, line 21, in
from .miele_at_home import MieleClient, MieleOAuth
File “/home/homeassistant/.homeassistant/custom_components/miele/miele_at_home.py”, line 7, in
from requests_oauthlib import OAuth2Session
ModuleNotFoundError: No module named ‘requests_oauthlib’
2018-09-09 13:25:59 ERROR (SyncWorker_17) [homeassistant.loader] Unable to find component miele
2018-09-09 13:26:04 ERROR (SyncWorker_1) [homeassistant.loader] Error loading custom_components.miele. Make sure all dependencies are installed
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/loader.py”, line 94, in get_component
module = importlib.import_module(path)
File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/home/homeassistant/.homeassistant/custom_components/miele/init.py”, line 21, in
from .miele_at_home import MieleClient, MieleOAuth
File “/home/homeassistant/.homeassistant/custom_components/miele/miele_at_home.py”, line 7, in
from requests_oauthlib import OAuth2Session
ModuleNotFoundError: No module named ‘requests_oauthlib’
2018-09-09 13:26:04 ERROR (SyncWorker_1) [homeassistant.loader] Unable to find component miele
2018-09-09 13:26:04 ERROR (MainThread) [homeassistant.components] Component not found: miele

As mentioned in the instructions, you need to install requests_oauthlib. You probably did that for Python 3.5, seems you need to do that again for 3.7

Thanks! I can see in the log file that it looks like requests_oauthlib is missing. However, I have indeed installed it. This is what happens what I try to install it again:

pi@hassbian:~ $ pip3 install requests_oauthlib
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: requests_oauthlib in /usr/local/lib/python3.7/site-packages (1.0.0)
Requirement already satisfied: oauthlib>=0.6.2 in /usr/local/lib/python3.7/site-packages (from requests_oauthlib) (2.1.0)
Requirement already satisfied: requests>=2.0.0 in /usr/local/lib/python3.7/site-packages (from requests_oauthlib) (2.19.1)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.0.0->requests_oauthlib) (1.23)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.0.0->requests_oauthlib) (2018.8.24)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.0.0->requests_oauthlib) (3.0.4)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.0.0->requests_oauthlib) (2.7)

I have tried all of the below:
sudo pip install requests-oauthlib
sudo pip install requests requests-oauthlib
sudo pip3 install requests-oauthlib
sudo pip3 install requests requests-oauthlib
sudo apt-get install -y python3-oauth python3-oauth2client python3-oauthlib python3-requests-oauthlib

but still same error message in .log file: ModuleNotFoundError: No module named ‘requests_oauthlib’

Any suggestions?

Update, after some hours of reading up on Python, venv etc I managed to make it work! :slight_smile:

If someone else has the same problem, this is what I did:

cd /srv/
sudo chown homeassistant:homeassistant homeassistant
sudo su -s /bin/bash homeassistant
cd /srv/homeassistant
source bin/activate
pip3 install requests_oauthlib

…now I will start using the Miele components :slight_smile:

Thanks a million for pulling this hack together. It’s great fun to be able to flash the lights upstairs when the washing machine in the basement has finished :slight_smile:

One quick question - it does not seem like the ‘lang: en’ argument is working? The sensors always report in German language, e.g., ‘Aus’.

Hi,
trying to get this component up and running - installed the oauthlib, added the repository to custom_components, added the code to configuration.yaml…
The component is discovered when I restart Home Assistant, but when I try to authorise something goes wrong:
I’m redirected to a webpage with the adress "http://[not-shown-here]/api/miele/callback?code=[not-shown-here]&state=login saying “This site can’t be reached”
Probably something very simple I didn’t do right - any suggestions?
Thanks in advance!

I’m starting to do some scripting and automations.
Here’s one that speaks the remaining duration with a media player (with a custom google home voice command for example):

speak_washingmachine_state:
  alias: Speak Washingmachine State
  sequence:
    - service: tts.google_say
      data_template:
        entity_id: media_player.esszimmer
        language: "de"
        message: >
          Die Waschmaschine ist {{states.sensor.waschmaschine_status.state}}. Die Restdauer ist {{states.sensor.waschmaschine_remaining_time.state.split(":")[0] | regex_replace('^0', '')}} Stunden und {{states.sensor.waschmaschine_remaining_time.state.split(":")[1] | regex_replace('^0', '')}} Minuten.

and here is one that speaks when the washingmachine is finished:

- alias: Washing Machine finished
  trigger:
    - platform: state
      entity_id: sensor.waschmaschine_status
      from: 'In Betrieb'
      to: 'Ende'
  action:
    - service: tts.google_say
      entity_id: media_player.esszimmer
      data:
        message: "Die Wäsche ist fertig"
        language: "de"

Feel free to add more if you have any.

1 Like

Great custom component, followed the instructions and it works without problems. Thanks guys!

I couldn’t find further documentation though on what the API returns. For example what a specific programphase/-type and the three different temperature states actually mean. I have it connected to a W1 washing machine. Will have to reverse ‘engineer’ it I’m afraid.

I think the API is still very undocumented. The official documentation is at https://www.miele.com/developer/

For some weeks I have a problem with the language as well. Before it was German (I also have lang: de in my config) but now it is only Englisch which breaks my automations. Any idea what happened? Die Miele break it? Or aren’t you using the lang parameter at all?

Found it. The language is not passed on the refresh_devices method. Miele seems to implemented the en/de language switch now and changed the default to en (it was always de before, see @HA_jr’s post).
I created a PR with that fix in github.

This component runs very smoothly now for a long time. Do you plan to add it to the official home-assistant repo @docbobo?

The Miele component has stopped working for me. I get the following error message in home-assistant.log:

2018-11-17 16:30:49 ERROR (MainThread) [homeassistant.setup] Error during setup of component miele
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/setup.py”, line 145, in _async_setup_component
hass, processed_config)
File “/home/homeassistant/.homeassistant/custom_components/miele/init.py”, line 112, in async_setup
cache_path=cache)
File “/home/homeassistant/.homeassistant/custom_components/miele/miele_at_home.py”, line 80, in init
self.refresh_token()
File “/home/homeassistant/.homeassistant/custom_components/miele/miele_at_home.py”, line 104, in refresh_token
refresh_token=self._token[‘refresh_token’])
File “/srv/homeassistant/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py”, line 309, in refresh_token
self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
File “/srv/homeassistant/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py”, line 411, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File “/srv/homeassistant/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py”, line 379, in parse_token_response
validate_token_parameters(params)
File “/srv/homeassistant/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py”, line 389, in validate_token_parameters
raise MissingTokenError(description=“Missing access token parameter.”)
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.

Can someone please help me understand what is wrong? Many thanks!!!

I just want to add that this was caused since you were probably running hassbian :)! Hassbian runs home assistant in a virtual python environment so you need to install the dependencies in the virtual environment.

On your first try you probably installed it on your hostmachine outside the environment.

@all it might be an idea to add these instruction on the github readme file :)!

Thank you. You are absolutely correct that I am running Hassbian. Can you please clarify which dependencies I have to install? I think it is a bit strange since it used to work just fine about a month ago and I have not made any changes or new installations.