mileperhour / localtuya-homeassistant

local handling for Tuya devices
GNU General Public License v3.0
147 stars 667 forks source link

Task exception was never retrieved (HA 103.0) #5

Open RoSulek1 opened 4 years ago

RoSulek1 commented 4 years ago

I have some error in HA. I see the friendly name in group of switches, but not in entities (as switch)

Unexpected status() payload=b'\x10\xe2C\xd9\xff\xce\xc5|\xf8\xee\xd2\xf2\xe4sW\xc9\xd2\x84\x84\xca\xd7{N1$\xee\xcc>bbej'

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 408, in _async_add_entity await entity.async_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 286, in async_update_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 328, in _async_write_ha_state attr.update(self.device_state_attributes or {}) File "/config/custom_components/localtuya/switch.py", line 158, in device_state_attributes attrs[ATTR_CURRENT] = "{}".format(self._status['dps'][self._attr_current]) TypeError: byte indices must be integers or slices, not str

Nantero1 commented 4 years ago

+1 I see this error with new Gosund switches using the protocol version 2.2 according to the grabbed preferences.xml

2020-05-28 19:51:55 ERROR (SyncWorker_2) [custom_components.localtuya.pytuya] Unexpected status() payload=b'3.3\x00\x00\x00\x00\x00\x00\x05\x0b\x00\x00\x00\x011\xbb\xc2\x9ce\xc1\xf3\xbe\x07\xcd\xed\xea\xccc\x1dy\xaf\x8a\xb1\xd4\xc2\xbf\x98\xf9\xca\xfa\x17\x8b\xae-\xa5\x0f\xa6&\xc7\x05\xc7\xa9\x02\xf4\x1f\x0c\xce*`\xf7#6\xef\\1\x05\xe3\x99X ,\xa9!\x02>,\xb0\x8d_\xdf\x92\x9a\x92\xb4\x13\x0f* R\xa1j\xe5@.'
Failed to receive data from <IP_ADDRESS>. Raising Exception.
Failed to update status of device [<IP_ADDRESS>]

Seems to be an issue: https://github.com/jasonacox/powermonitor/issues/3

UPDATE: solved it by changing protocol_version: 3.3 in my config. It seems the protocol version is listed wrongly in the preferences.yaml. Hope this comment helps someone one day :)