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

viomivacuum doesn´t work with -o json_pretty #816

Closed
fs79 opened this issue Sep 13, 2020 · 3 comments · Fixed by #827
Closed

viomivacuum doesn´t work with -o json_pretty #816

fs79 opened this issue Sep 13, 2020 · 3 comments · Fixed by #827
Labels

Comments

@fs79
Copy link
Contributor

fs79 commented Sep 13, 2020

/miiocli -o json_pretty viomivacuum --ip x.x.x.x --token x1234567890x status
doesn´t work.
/miiocli viomivacuum --ip x.x.x.x --token x1234567890x status

  • OS: Raspbian GNU/Linux 10 \n \l
  • python-miio: miiocli, version 0.5.3

Device information:
It doesn´t work for the devicetype "viomivacuum".

Steps to reproduce the behavior:

  1. execute the status command with flag "-o json_pretty"

Expected behavior
Should work, the same as for type "vacuum"

Console output
root@loxb01:~# /usr/local/bin/miiocli -o json_pretty viomivacuum --ip x.x.x.x --token x1234567890x status
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 8, in
sys.exit(create_cli())
File "/usr/local/lib/python3.7/dist-packages/miio/cli.py", line 45, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.7/dist-packages/miio/click_common.py", line 59, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/miio/click_common.py", line 309, in wrap
click.echo(json.dumps(result, indent=indent))
File "/usr/lib/python3.7/json/init.py", line 238, in dumps
**kw).encode(obj)
File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
chunks = list(chunks)
File "/usr/lib/python3.7/json/encoder.py", line 438, in _iterencode
o = _default(o)
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 ViomiVacuumStatus is not JSON serializable

@rytilahti
Copy link
Owner

This is happening because ViomiVacuumStatus does not have __json__ method.

@fs79
Copy link
Contributor Author

fs79 commented Sep 13, 2020

@rytilahti
Ok. Who should implement?

@rytilahti
Copy link
Owner

@fs79 feel free to create a PR :-)

rytilahti added a commit that referenced this issue Oct 3, 2020
All implementations were simply returning the `data` for this request,
and forgetting to add this boilerplate piece causes problems like shown in #816.

This commit adds a lookup for `data` variable which should be consistent within all containers.
For the time being, this behavior can still be overridden by manually defining __json__.

Fixes #816
rytilahti added a commit that referenced this issue Oct 3, 2020
All implementations were simply returning the `data` for this request,
and forgetting to add this boilerplate piece causes problems like shown in #816.

This commit adds a lookup for `data` variable which should be consistent within all containers.
For the time being, this behavior can still be overridden by manually defining __json__.

Fixes #816
swim2sun pushed a commit to swim2sun/python-miio that referenced this issue Oct 13, 2020
…i#827)

All implementations were simply returning the `data` for this request,
and forgetting to add this boilerplate piece causes problems like shown in rytilahti#816.

This commit adds a lookup for `data` variable which should be consistent within all containers.
For the time being, this behavior can still be overridden by manually defining __json__.

Fixes rytilahti#816
xvlady pushed a commit to xvlady/python-miio that referenced this issue May 9, 2021
…i#827)

All implementations were simply returning the `data` for this request,
and forgetting to add this boilerplate piece causes problems like shown in rytilahti#816.

This commit adds a lookup for `data` variable which should be consistent within all containers.
For the time being, this behavior can still be overridden by manually defining __json__.

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

Successfully merging a pull request may close this issue.

2 participants