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

[bug] error near authentication: ValidationError devices missing in DeviceList #26

Open
bastienboutonnet opened this issue Oct 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@bastienboutonnet
Copy link
Owner

As of today, I started getting the following error:

  Stack trace:

  7  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/clikit/console_application.py:131 in run
     status_code = command.handle(parsed_args, io)

  6  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/clikit/api/command/command.py:120 in handle
     status_code = self._do_handle(args, io)

  5  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/clikit/api/command/command.py:171 in _do_handle
     return getattr(handler, handler_method)(args, io, self)

  4  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/cleo/commands/command.py:92 in wrap_handle
     return self.handle()

  3  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/py_nest_thermostat/main.py:44 in handle
     thermostat.get_device_stats(

  2  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/py_nest_thermostat/nest_api.py:139 in get_device_stats
     self.get_devices(print_controlled_device_name)

  1  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/py_nest_thermostat/nest_api.py:107 in get_devices
     self.device_list = DeviceList(**devices_response.json())

  ValidationError

  1 validation error for DeviceList
  devices
    field required (type=value_error.missing)

  at .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/pydantic/main.py:406 in __init__
       402│         """
       403│         # Uses something other than `self` the first arg to allow "self" as a settable attribute
       404│         values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
       405│         if validation_error:
    →  406│             raise validation_error
       407│         try:
       408│             object_setattr(__pydantic_self__, '__dict__', values)
       409│         except TypeError as e:
       410│             raise TypeError(
(base) ➜  ~ nest stats -vvv
[12:48:04] DEBUG    No need to authenticate, auth code is still valid                                                                                                                auth.py:72

  Stack trace:

  7  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/clikit/console_application.py:131 in run
      129│             parsed_args = resolved_command.args
      130│
    → 131│             status_code = command.handle(parsed_args, io)
      132│         except KeyboardInterrupt:
      133│             status_code = 1

  6  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/clikit/api/command/command.py:120 in handle
      118│     def handle(self, args, io):  # type: (Args, IO) -> int
      119│         try:
    → 120│             status_code = self._do_handle(args, io)
      121│         except KeyboardInterrupt:
      122│             if io.is_debug():

  5  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/clikit/api/command/command.py:171 in _do_handle
      169│         handler_method = self._config.handler_method
      170│
    → 171│         return getattr(handler, handler_method)(args, io, self)
      172│
      173│     def __repr__(self):  # type: () -> str

  4  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/cleo/commands/command.py:92 in wrap_handle
       90│         self._command = command
       91│
    →  92│         return self.handle()
       93│
       94│     def handle(self):  # type: () -> Optional[int]

  3  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/py_nest_thermostat/main.py:44 in handle
      42│             log.setLevel(logging.DEBUG)
      43│         thermostat = NestThermostat(AUTHENTICATOR, config=config)
    → 44│         thermostat.get_device_stats(
      45│             no_print=self.option("no-print"), save_stats=self.option("save-to-db")  # type: ignore
      46│         )

  2  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/py_nest_thermostat/nest_api.py:139 in get_device_stats
      137│     ):
      138│         # TODO: think about replacing the key access by gets when there is a chance that the attribute it not present.
    → 139│         self.get_devices(print_controlled_device_name)
      140│         assert self.device_list, "device_list cannot be None"
      141│         self.active_device: Optional[Device] = self.device_list.devices[0]

  1  .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/py_nest_thermostat/nest_api.py:107 in get_devices
      105│
      106│         if devices_response.status_code == 200:
    → 107│             self.device_list = DeviceList(**devices_response.json())
      108│
      109│             # TODO: we need to allow users to choose their device as there may be more than one

  ValidationError

  1 validation error for DeviceList
  devices
    field required (type=value_error.missing)

  at .local/pipx/venvs/py-nest-thermostat/lib/python3.10/site-packages/pydantic/main.py:406 in __init__
       402│         """
       403│         # Uses something other than `self` the first arg to allow "self" as a settable attribute
       404│         values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
       405│         if validation_error:
    →  406│             raise validation_error
       407│         try:
       408│             object_setattr(__pydantic_self__, '__dict__', values)
       409│         except TypeError as e:
       410│             raise TypeError(

It is likely that something has changed in the output of the API and we'll have to explore this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant