beele / HomebridgeLgSmartThinqAirco

Homebridge plugin for controlling a split unit LG SmartThinq Airco unit
GNU General Public License v3.0
30 stars 7 forks source link

Unable to Parse Status #18

Closed lupiter closed 4 years ago

lupiter commented 4 years ago

I've updated to the latest (0.1.2) and I was at quite an old version (0.999). I deleted the wideq_state in the node_modules and in the homebrew dir, and re-ran example.py.

But it seems to be writing a wideq_state that isn't valid JSON. It is frequently raising an exception like the one below:

  File "example.py", line 306, in <module>
    main()
  File "example.py", line 302, in main
    example(args.country, args.language, args.path, args.verbose, args.cmd, args.args)
  File "example.py", line 219, in example
    state = json.load(f)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 1 column 16439 (char 16438)

I turned on the debug mode in config, and that's showing that it is correctly reading the information sometimes. Sometimes it will fail at homebridge start. It seems like perhaps there's some concurrent access to the state file happening?

I have opened the state file to look at the JSON, and sometimes its fine and sometimes it seems to have gotten truncated.

Let me know if there's anything else I can do to help debug this for you, and thanks very much for making this module!

beele commented 4 years ago

I'm actually having the same issue that sometimes the python wideq lib is corrupting its own state file. Still looking for a solution though

serbasan commented 4 years ago

The same here. I didn't know why it sometimes failed me and it was because of a json error in that file.

serbasan commented 4 years ago

After a day running, stop working with this log:


  File "example.py", line 310, in <module>

    main()
  File "example.py", line 306, in main

    example(args.country, args.language, args.path, args.verbose, args.cmd, args.args)
  File "example.py", line 219, in example

    state = json.load(f)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load

    return loads(fp.read(),
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads

    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode

    raise JSONDecodeError("Expecting value", s, err.value) from None

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Traceback (most recent call last):
  File "example.py", line 310, in <module>

    main()

  File "example.py", line 306, in main

    example(args.country, args.language, args.path, args.verbose, args.cmd, args.args)
  File "example.py", line 219, in example

    state = json.load(f)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load

    return loads(fp.read(),

  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads

    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

(node:4541) UnhandledPromiseRejectionWarning: Error: Could not change isOn state of the AC unit!
    at LgAircoController.setPowerState (/homebridge/node_modules/homebridge-lg-airco/src/lg/lg-airco-controller.ts:45:23)
(node:4541) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4541) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[7/3/2020, 9:30:42 AM] [Camera ffmpeg] Snapshot from Default Camera at 480:270
Traceback (most recent call last):
  File "example.py", line 310, in <module>

    main()
  File "example.py", line 306, in main

    example(args.country, args.language, args.path, args.verbose, args.cmd, args.args)
  File "example.py", line 219, in example

    state = json.load(f)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load

    return loads(fp.read(),

  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads

    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode

    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode

    raise JSONDecodeError("Exp
beele commented 4 years ago

Yeah the issue keeps happening to me too. I'm investigating it. For now I have made a backup of the state file (wideq_state2.json) and when this happens I copy over the state file with the backup. cp wideq_state2.json wideq_state.json

beele commented 4 years ago

The newest version should have fixed this (0.1.4)