lolouk44 / CurrentCost_HA_CC

CurrentCost Meter Reading Custom Component for Home Assistant
16 stars 7 forks source link

Support intermittent serial comms #17

Closed hanscomps closed 1 year ago

hanscomps commented 1 year ago

name: Bug report about: Create a report to help us improve title: '' labels: bug assignees: ''


Describe the bug For unknown reasons my currentcost usb-serial interface loses connection intermittently. In the process the script crashes and is dead/unresponsive until hass is restarted.

To Reproduce Steps to reproduce the behaviour, including error message if any.

Expected behaviour Gracefully handle any serial port failures and recover. By adding a <try, except> over the reader.readline the scripts seems to recover properly. Probably have to add some delay or timeout in exception handling to prevent excessive logging.

    while True:
        try:
            line = await reader.readline()
            line = line.decode("utf-8").strip()
            _LOGGER.debug("Line Received: %s", line)
        except:
            _LOGGER.error("Error reading from serial port")

Screenshots If applicable, add screenshots to help explain your problem.

Desktop/Server/Device (please complete the following information):

Additional context Add any other context about the problem here.

Logs Please set the Current Cost Custom Component's logging level to debug and provide relevant logs section from Home-Assistant. To Enable debug logging level, add this to your configuration.yaml and restart:

logger:
  default: error
  logs:
    custom_components.currentcost: debug
lolouk44 commented 1 year ago

Fixed in 0.2.3

lolouk44 commented 1 year ago

Thanks