One more thing: you need to
pip3 install requests_oauthlib
Iâll try to write a more complete installation guide later this week, if time permits.
One more thing: you need to
pip3 install requests_oauthlib
Iâll try to write a more complete installation guide later this week, if time permits.
Now it works thatnks, the oauthlib was for some reason already installed. I see that a whole device is in one sensor, having on/off as a state and the rest as attributes. Is this the correct way? Is it possible to get a history about the attributes and display them easily (the most important thing I guess is to show a remaining time counter in home assistant) or should each value be exposed as an own sensor/binary_sensor?
Glad you got it up and running, @Roemer.
As I said, the current is a little bit of a hack. Hereâs what I am thinking though: each device should be exposed as miele.<device-name>
. That entity would expose all the information that the Miele developer documentation has under ident
. In addition, information available from state
should be exposed like this:
In the meantime, you should be able to do all of that via template sensors. For example:
binary_sensor:
- platform: template
sensors:
dishwasher_door:
friendly_name: "Dishwasher door"
value_template: {{ states.sensor.dishwasher.attributes.signalDoor }}
should expose the state of the dishwasher door for sensor.dishwasher
as separate attribute, if I didnât make any mistake.
Sounds great how you plan to expose the devices / sensors. Iâm getting btw some errors from time to time:
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity.py", line 210, in async_update_ha_state
state = self.state
File "/config/custom_components/sensor/miele.py", line 213, in state
state = DeviceState(self._home_device['state']['status']['value_raw'])
File "/usr/local/lib/python3.6/enum.py", line 291, in __call__
return cls.__new__(cls, value)
File "/usr/local/lib/python3.6/enum.py", line 533, in __new__
return cls._missing_(value)
File "/usr/local/lib/python3.6/enum.py", line 546, in _missing_
raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 10 is not a valid DeviceState
It is probably when the dishwasher is open as that is the only thing we did today
Okay, I did some refactoring today and pushed that to GitHub. The change does require some configuration change:
miele:
client_id: <client id received from Miele>
client_secret: <client id received from Miele>
lang: <either en or de>
This should expose binary_sensors and sensors as described above.
The error you were reporting should be gone because that mapping was removed for now. However, Iâve never seen a state of 10 with any of my devices, so it would in general be interesting to see what it means. But that has to wait for when that mapping gets back into the code.
Works great
Although it is adding quite some sensors and most are only interested in a few. Maybe it should be configurable which sensors are loaded like in https://community.home-assistant.io/t/writing-a-component-for-luxtronik-heatpumps?
State 10 is âOnâ on my dishwasher:
"state": {
"status": {
"key_localized": "Status",
"value_raw": 10,
"value_localized": "Ein"
},
Edit: That is when the dishwasher is just opened and the LEDs are on. When i actively turn it on, the state changes to 3: Programm choosen
Yes, itâs pretty verbose now. I think Iâll merge programType, programPhase and the device state as they seem to be tightly coupled.
Not sure about the best way to filter though. Perhaps thereâs also an option to hide some sensors via the customizerâŚ
I see that you reworked it quite a bit. Will install the newest version and test it. Yesterday the error log was flodded with the error:
2018-08-22 15:08:56 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File â/usr/src/app/homeassistant/helpers/entity.pyâ, line 210, in async_update_ha_state
state = self.state
File â/config/custom_components/sensor/miele.pyâ, line 163, in state
state_value = self._device[âstateâ][self._key][self._index][âvalue_rawâ]
and
2018-08-22 15:09:02 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File â/usr/src/app/homeassistant/helpers/entity.pyâ, line 210, in async_update_ha_state
state = self.state
File â/usr/src/app/homeassistant/components/binary_sensor/init.pyâ, line 81, in state
return STATE_ON if self.is_on else STATE_OFF
File â/config/custom_components/binary_sensor/miele.pyâ, line 66, in is_on
return bool(self._device[âstateâ][self._key])
KeyError: âsignalInfoâ
with KeyError âsignalInfoâ, âsignalDoorâ and âsignalFailureâ.
I will observe if this happens with the new version as well.
Interesting. The responses from the cloud service are pretty static in their structure. If there was a sensor for e.g. signalInfo, that value should always be present.
Said that, it might be possible that some outage or connection error resulted in this downstream error. If so, I would suspect those errors to go away due to the recent changes.
Let me know how things go.
Hmm the error started when the devices switched from âOffâ (Aus) to âNot Connectedâ (Nicht Verbunden) (state_raw: 255). When I manually get the data with the API the devices still show âOffâ. I checked the token, it should still be valid. Do you know how this can happen? Also turning a device off didnât change a thing, still âNot connectedâ but with my own API call, they work correctly.
The code polls the Miele service every five seconds. So a little bit of a delay would be expected when compared to directly calling the API. If you set the log level to debug by adding the following to your config, you should the some output whenever a request to the cloud service is made.
logger:
default: info
logs:
custom_components.miele.miele_at_home: debug
I did notice one device (connected via zigbee) to switch to âNot connectedâ from time to time, but thatâs consistent with what I see in the mobile app. Plus, Iâve seen this before, so it didnât come as a surprise.
They are âNot connectedâ for almost a day now and never went back to âoffâ. I now deleted the miele-token-cache, restarted HA, logged in into miele again and now the devices are back to âoffâ. I will observe this an check if this happens again (this time it happened after 18 hours after logging in).
Sounds as if the OAuth token expired. Iâll have a look later to see if this can be properly simulated. Did you see any other messages in the log? The device request should fail with Unauthorized in that case.
Also, if that happens again could you try to use the token from the cache file?
No other messages in the log. The tokens are valid for about 1 month (according to the unixtime that was in the file). Yes, next time I see this Iâll try the token from the cache file in a manual api call.
I believe token refresh should work properly now.
I also added âprogressâ and âfinishTimeâ as attributes to status. For now, both can be extracted into distinct sensors by using a template sensor as described above.
Wow nice
I think I know why my devices suddenly got a not connected:
I generated a new token with my other script. I guess that this token replaced the old one and therefore Home Assistant could not connect to it anymore.
Are you also planning on adding kind of âeventsâ, like when a programm is finished? Or should this be done with automations / scripts?
Many thanks for driving this development. I have copied the files to customs_components, installed requests_oauthlib and added the following to my configuration.yaml:
sensor:
When pressing âCheck configâ in HA, the wait icon appears but there is never a response.
I have anyways restarted HA. It works but there is no link to Miele shown. Also, I have the following text in the log file:
File â/srv/homeassistant/lib/python3.5/site-packages/aiohttp/helpers.pyâ, line 462, in log
for key, value in fmt_info:
File â/srv/homeassistant/lib/python3.5/site-packages/aiohttp/helpers.pyâ, line 454, in
for key, method in self._methods)
File â/srv/homeassistant/lib/python3.5/site-packages/aiohttp/helpers.pyâ, line 412, in _format_a
ip = request.remote
File âaiohttp_helpers.pyxâ, line 32, in aiohttp._helpers.reify.get
File âaiohttp_helpers.pyxâ, line 26, in aiohttp._helpers.reify.get
File â/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_request.pyâ, line 343, in remote
peername = self.transport.get_extra_info(âpeernameâ)
File â/usr/lib/python3.5/asyncio/sslproto.pyâ, line 306, in get_extra_info
return self._ssl_protocol._get_extra_info(name, default)
File â/usr/lib/python3.5/asyncio/sslproto.pyâ, line 546, in _get_extra_info
return self._transport.get_extra_info(name, default)
AttributeError: âNoneTypeâ object has no attribute âget_extra_infoâ
Any ideas on what can be wrong?