core: Samsung SyncThru Printer doesn’t reconnect printer

The problem

The Samsung SyncThru Printer integration doesn’t properly reconnect with my Samsung C48x Series printer. This happens when this printer gets power cycled while home assistant remains running. It gets in a connect/disconnect cycle (see log below). Reload of the integration is needed to fix the issue.

What version of Home Assistant Core has the issue?

2021.12.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Samsung SyncThru

Link to integration documentation on our website

https://www.home-assistant.io/integrations/syncthru/

Example YAML snippet

-

Anything in the logs that might be useful for us?

Logger: homeassistant.components.syncthru
Source: components/syncthru/__init__.py:38 
Integration: Samsung SyncThru Printer (documentation, issues) 
First occurred: 15:18:45 (8 occurrences) 
Last logged: 15:23:15

Unexpected error fetching syncthru data: Invalid host, does not support SyncThru JSON API.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pysyncthru/__init__.py", line 82, in _current_data
    res = demjson3.decode(
  File "/usr/local/lib/python3.9/site-packages/demjson3.py", line 6423, in decode
    result = j.decode(
  File "/usr/local/lib/python3.9/site-packages/demjson3.py", line 5607, in decode
    raise errors[0]
demjson3.JSONDecodeError: ('Line terminator characters must be escaped inside string literals', 'U+000A')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/syncthru/__init__.py", line 46, in async_update_data
    raise api_error
  File "/usr/src/homeassistant/homeassistant/components/syncthru/__init__.py", line 38, in async_update_data
    await printer.update()
  File "/usr/local/lib/python3.9/site-packages/pysyncthru/__init__.py", line 69, in update
    self.data = await self._current_data()
  File "/usr/local/lib/python3.9/site-packages/pysyncthru/__init__.py", line 94, in _current_data
    raise SyncThruAPINotSupported(
pysyncthru.SyncThruAPINotSupported: Invalid host, does not support SyncThru JSON API.

Additional information

The printer Itself is working normally. It is only the integration that doesn’t reconnect properly.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 29 (3 by maintainers)

Most upvoted comments

That bug is solved in #97843. That is different from this issue! It will be fixed with the 2023.8.2

This is still an issue

I’ve just submitted a PR for the pysyncthru library that hopefully fixes this.

Hm the error message suggests that the printer does sometimes send invalid JSON (maybe when queried while power cycling?) If you could provide me with the content of http://<ip of printer>/sws/app/information/home/home.json I can try to handle that manually. I unfortunately own none of the mentioned devices for reproducing.

i have the same problem. Configured printer does not respond