Broadlink temperature error

Hi, since the last update, hasss.io 0.52.1, I’ve been getting the following error…

2017-09-07 08:38:26 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.broadlink_sensor_temperature fails
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/broadlink.py", line 96, in update
    self._broadlink_data.update()
  File "/usr/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
    result = method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/broadlink.py", line 134, in _update
    if retry > 0 and self._auth():
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/broadlink.py", line 139, in _auth
    auth = self._device.auth()
  File "/usr/lib/python3.6/site-packages/broadlink/__init__.py", line 205, in auth
    payload = self.decrypt(response[0x38:])
  File "/usr/lib/python3.6/site-packages/broadlink/__init__.py", line 174, in decrypt_pycrypto
    return aes.decrypt(bytes(payload))
  File "/usr/lib/python3.6/site-packages/Crypto/Cipher/_mode_cbc.py", line 209, in decrypt
    raise ValueError("Error %d while decrypting in CBC mode" % result)
ValueError: Error 3 while decrypting in CBC mode

After a restart of HA it works fine for a few hours and then errors and sticks at the last temperature.

Any ideas please?

@Danielhiversen

Update to 0.53 seems to have fixed it!

I’m getting this exact problem in 0.59.2:

Update for sensor.living_room_temperature fails
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
    yield from self.async_device_update()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
    yield from self.hass.async_add_job(self.update)
  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/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/broadlink.py", line 96, in update
    self._broadlink_data.update()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/components/sensor/broadlink.py", line 124, in _update
    data = self._device.check_sensors_raw()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/broadlink/__init__.py", line 449, in check_sensors_raw
    payload = self.decrypt(bytes(response[0x38:]))
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/broadlink/__init__.py", line 174, in decrypt_pycrypto
    return aes.decrypt(bytes(payload))
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/Crypto/Cipher/_mode_cbc.py", line 209, in decrypt
    raise ValueError("Error %d while decrypting in CBC mode" % result)
ValueError: Error 3 while decrypting in CBC mode

Any ideas?

Afraid not, my reliability didn’t last long.

This is the first I’m seeing the error and I’ve been using HA since 0.56. I’ll submit an issue…

Actually I haven’t lost any reliability in the sensor at all so these logs are a little confusing to me…

That’s odd, I just went to my log to copy the bit where it gives up after the third error but since the last restart 3 days ago it worked fine for a day and then it’s just getting this pair over and over…

2017-12-09 10:54:53 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.broadlink_sensor_temperature is taking over 10 seconds
2017-12-09 10:55:14 WARNING (MainThread) [homeassistant.components.sensor] Updating broadlink sensor took longer than the scheduled update interval 0:00:30

Front end just displays temp from when it broke.

Hmm, that is odd. So your broadlink temp has frozen on one value? Mine is still functioning fine and I haven’t seen those errors for the whole day so far. I’ve done a reboot of all the devices though…

Yep, it usually lasts around a day working perfectly after a restart, then previously it was giving the big error three times and then announces it’s a fatal error or similar and stops trying.

The front end currently shows the temperature from the last successful pole and with a flat line graph, as the scale is now part where it stopped, stating the temp is from 2 days ago.

Restarting HA always gets it going again, rebooting Broadlink makes no difference. I updated the firmware about a week ago and I’m running 59.2 Hass.io