Leggin / dirigera

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

Creating scene with trigger does not match any of the allowed types #73

Closed slajob closed 7 months ago

slajob commented 7 months ago

I tried to create a empty scene and it works well when triggers and actions are empty. But I can't create a scene with assigned trigger. Using this code:

trigger = Trigger(id="b55c75ec-829c-4623-a167-0b537569c9e2_1", type="device",triggered_at=datetime.now(), disabled=False)
action = Action(id="b55c75ec-829c-4623-a167-0b537569c9e2_1", type="device", disabled=False)
dirigera_hub.create_scene(info=Info(name="ha_dir-pla_test_test1_test2", icon=Icon.SCENES_CLEAN_SPARKLES), triggers=[trigger], actions=[action])

I getting error:

Traceback (most recent call last):
  File "/Users/slajob/git/dirigera_local/shortcut-somrig.py", line 24, in <module>
    dirigera_hub.create_scene(info=Info(name="ha_dir-pla_test_test1_test2", icon=Icon.SCENES_CLEAN_SPARKLES), triggers=[trigger], actions=[action])
  File "/Users/slajob/git/dirigera_local/venv/lib/python3.9/site-packages/dirigera/hub/hub.py", line 421, in create_scene
    response_dict = self.post(
  File "/Users/slajob/git/dirigera_local/venv/lib/python3.9/site-packages/dirigera/hub/hub.py", line 132, in post
    response.raise_for_status()
  File "/Users/slajob/git/dirigera_local/venv/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://192.168.0.73:8443/v1/scenes/
{"error":"Error","message":"\"triggers[0]\" does not match any of the allowed types"}

Have you ever tried creating scene with trigger assigned?

bjorncs commented 7 months ago

@Leggin @slajob I managed to create a scene with a controller trigger in https://github.com/Leggin/dirigera/pull/74.

Leggin commented 7 months ago

Thanks you two!