Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export to json not working #28

Closed
chinezbrun opened this issue Jan 10, 2021 · 2 comments
Closed

export to json not working #28

chinezbrun opened this issue Jan 10, 2021 · 2 comments

Comments

@chinezbrun
Copy link

0.5.3 export to json was ok, starting with 0.6.0 give below error

pi@raspberrypi:~ $ mate3 read --host 192.168.0.150 -f json >mate3_060.json

2021-01-10 19:35:24.682 | WARNING  | mate3.api:_read_model:165 - Error reading field gateway_type - so setting as not implemented. Message: 3 is not a valid gateway_type
2021-01-10 19:35:24.701 | WARNING  | mate3.api:_read_model:165 - Error reading field inverter_operating_mode - so setting as not implemented. Message: 12 is not a valid inverter_operating_mode
Traceback (most recent call last):
  File "/home/pi/.local/bin/mate3", line 8, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/mate3/main.py", line 199, in main
    read(client, args)
  File "/home/pi/.local/lib/python3.7/site-packages/mate3/main.py", line 59, in read
    print(json.dumps(devices, indent=indent))
  File "/usr/lib/python3.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type FieldValue is not JSON serializable
@chinezbrun chinezbrun changed the title 0.6.0 - export to json not working export to json not working Jan 10, 2021
@kodonnell
Copy link
Collaborator

0.5.3 export to json was ok, starting with 0.6.0 give below error

Good spotting! I added basic CLI tests in 0.6.1 (as the previous tests weren't checking the CLI), but only did the basic stuff for now (i.e. reading to text format). I'm glad I did that, 'cos now I've added in a test that reproduced this error (i.e. reading to json), and fixed it in #29 .

@kodonnell
Copy link
Collaborator

Oh, just to be clear, it's fixed in 0.6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants