d03n3rfr1tz3 / hass-divoom

Divoom Integration for Home Assistant
MIT License
111 stars 9 forks source link

Notify Service Failing with ESP32 Proxy #38

Closed FritzBlaskowsky closed 4 months ago

FritzBlaskowsky commented 4 months ago

Hi! I'm using the esp32-divoom proxy. The notify service call in HA fails unless I turn on debug logging in the hass-divoom integration.

File "/config/custom_components/divoom/notify.py", line 226, in send_message self._device.reconnect(skipPing=skipPing) File "/config/custom_components/divoom/devices/divoom.py", line 126, in reconnect if (self.host != None and list(ping)[-1] == 0x69): ^^^^^^^^^^ TypeError: 'int' object is not iterable

I think this might be related to this part of the send_payload function:

if skipRead == False and self.logger.isEnabledFor(logging.DEBUG):
    ready = select.select([self.socket], [], [], 0.2)
    if ready[0]:
        response = self.socket.recv(1024)
        self.logger.debug("{0} PAYLOAD IN: {1}".format(self.type, ' '.join([hex(b) for b in response])))
        return response or result

return result

The response is only being read if debug logging is turned on.

d03n3rfr1tz3 commented 4 months ago

Changed the behavior and tested it with debug disabled connecting with and without the ESP32 Proxy. Both worked now including the special proxy cases, for which the code initially was intended. Let me know if there are still such problems.