Leggin / dirigera

This repository provides an unofficial Python client for controlling the IKEA Dirigera Smart Home Hub.
MIT License
116 stars 21 forks source link

get_scenes gives pydantic ValidationError #42

Closed RasmusMalver closed 8 months ago

RasmusMalver commented 8 months ago
# python3
dirigera_hub.get_scenes()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    dirigera_hub.get_scenes()
  File "~/Gits/IKEA-smart-home/lib/python3.11/site-packages/dirigera/hub/hub.py", line 258, in get_scenes
    return [dict_to_scene(scene, self) for scene in scenes]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Gits/IKEA-smart-home/lib/python3.11/site-packages/dirigera/hub/hub.py", line 258, in <listcomp>
    return [dict_to_scene(scene, self) for scene in scenes]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Gits/IKEA-smart-home/lib/python3.11/site-packages/dirigera/devices/scene.py", line 66, in dict_to_scene
    return Scene(dirigeraClient=dirigera_client, **data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Gits/IKEA-smart-home/lib/python3.11/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Scene
lastUndo
  Field required [type=missing, input_value={'dirigeraClient': <dirig...ndoAllowedDuration': 30}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing

I've tried on MacOS and on Debian, but I run into this, when I try to interact with scenes on my IKEA Dirigera. I've booted everything, deleted all scenes, added them again, but I keep ending here.

Leggin commented 8 months ago

Thank you for reporting this, I will fix it asap and deploy a new version!

RasmusMalver commented 8 months ago

Thank you for reporting this, I will fix it asap and deploy a new version!

I tried to understand the problem myself, but it was more complex than my skillset could handle 🙂

RasmusMalver commented 8 months ago

I'm sorry to be a bother, but I get the same error. I've tried making a new venv, and installing from scratch, and I've checked that the committed changes have been made. Do I need to generate a new token from my Dirigera?

dirigera_hub.get_scenes()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    dirigera_hub.get_scenes()
  File "~/Gits/IKEA-2/lib/python3.11/site-packages/dirigera/hub/hub.py", line 257, in get_scenes
    return [dict_to_scene(scene, self) for scene in scenes]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Gits/IKEA-2/lib/python3.11/site-packages/dirigera/hub/hub.py", line 257, in <listcomp>
    return [dict_to_scene(scene, self) for scene in scenes]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Gits/IKEA-2/lib/python3.11/site-packages/dirigera/devices/scene.py", line 66, in dict_to_scene
    return Scene(dirigeraClient=dirigera_client, **data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/Gits/IKEA-2/lib/python3.11/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Scene
lastUndo
  Field required [type=missing, input_value={'dirigeraClient': <dirig...ndoAllowedDuration': 30}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
Leggin commented 8 months ago

I'm sorry I made the wrong fields optional, I will make a corrected version.

Leggin commented 8 months ago

ok please try again with version 1.0.6, it should hopefully work now.