sanjoyg / dirigera_platform

HomeAssistant Integration for Dirigera Platform
MIT License
122 stars 16 forks source link

Motion Sensor not working #15

Closed drunken3agle closed 8 months ago

drunken3agle commented 8 months ago

Automation for turning on lights based on motion sensors causes the following error: 2024-03-09 13:32:39.599 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up dirigera_platform platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/dirigera_platform/sensor.py", line 55, in async_setup_entry hub_controllers = await hass.async_add_executor_job(hub.get_controllers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/dirigera/hub/hub.py", line 237, in get_controllers return [dict_to_controller(controller, self) for controller in controllers] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/dirigera/devices/controller.py", line 34, in dict_to_controller return Controller(dirigeraClient=dirigera_client, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 341, in __init__ raise validation_error pydantic.error_wrappers.ValidationError: 1 validation error for Controller room field required (type=value_error.missing)

Automation: image

Toggling lights manually works. Home Assistant runs in Docker container.

sanjoyg commented 8 months ago

Will have a look, could you please turn debug on in the integration and then paste the log as well. Seems like the issue is with a controller added not the automation.

sanjoyg commented 8 months ago

for me to debug this better, can you please enable debug mode call the service and paste the JSON dump

sanjoyg commented 8 months ago

Can you look at the HASS automation trace and see whats happening. I tried with mock motion sensor and mock light bulbs.. and it worked well.

drunken3agle commented 8 months ago

{ "trace": { "last_step": "action/2", "run_id": "800a52790866fd32d9d97c3ad176a7b1", "state": "stopped", "script_execution": "finished", "timestamp": { "start": "2024-03-11T16:19:11.409816+00:00", "finish": "2024-03-11T16:21:20.241052+00:00" }, "domain": "automation", "item_id": "1709986271409", "trigger": null, "trace": { "trigger": [ { "path": "trigger", "timestamp": "2024-03-11T16:19:11.409874+00:00", "changed_variables": { "this": { "entity_id": "automation.hallway_lights", "state": "on", "attributes": { "id": "1709986271409", "last_triggered": "2024-03-09T12:24:06.513670+00:00", "mode": "single", "current": 0, "friendly_name": "Hallway Lights" }, "last_changed": "2024-03-09T12:32:37.421958+00:00", "last_updated": "2024-03-09T12:32:37.421958+00:00", "context": { "id": "01HRHK6W1DS5HFNA1VR1BF41VJ", "parent_id": null, "user_id": null } }, "trigger": { "platform": null } } } ], "action/0": [ { "path": "action/0", "timestamp": "2024-03-11T16:19:11.414198+00:00", "changed_variables": { "context": { "id": "01HRQ4Z5DH9ZC3VFP0WGYRNT1P", "parent_id": "01HRQ4Z5DHFBQSMMD6305BMM53", "user_id": null } }, "result": { "params": { "domain": "light", "service": "turn_on", "service_data": { "brightness_pct": 80, "device_id": [ "f0208c60ce4297cc528f81ee33da3a32", "21787f4f32577c124e34685f355021e9", "b76b7a78078cd35dcb7fa1d33cc564d4", "8993ec221435d3072ad1e0cf96b590f8" ] }, "target": { "device_id": [ "f0208c60ce4297cc528f81ee33da3a32", "21787f4f32577c124e34685f355021e9", "b76b7a78078cd35dcb7fa1d33cc564d4", "8993ec221435d3072ad1e0cf96b590f8" ] } }, "running_script": false } } ], "action/1": [ { "path": "action/1", "timestamp": "2024-03-11T16:19:16.855187+00:00", "result": { "delay": 120, "done": true } } ], "action/2": [ { "path": "action/2", "timestamp": "2024-03-11T16:21:16.859054+00:00", "result": { "params": { "domain": "light", "service": "turn_off", "service_data": {}, "target": { "device_id": [ "f0208c60ce4297cc528f81ee33da3a32", "21787f4f32577c124e34685f355021e9", "b76b7a78078cd35dcb7fa1d33cc564d4", "8993ec221435d3072ad1e0cf96b590f8" ] } }, "running_script": false } } ] }, "config": { "id": "1709986271409", "alias": "Hallway Lights", "description": "Turn on hallway lights on motion", "trigger": [ { "type": "turned_on", "platform": "device", "device_id": "5e3beda267035f634fac95c9ec2202c4", "entity_id": "210b67cbc7d2fc33ee78df7bb981458b", "domain": "binary_sensor" }, { "type": "turned_on", "platform": "device", "device_id": "2d8d7cbaf67c49bdb911f44f861b3597", "entity_id": "ea8ed645927e27f7e3713d3ab572e308", "domain": "binary_sensor" } ], "condition": [], "action": [ { "service": "light.turn_on", "metadata": {}, "data": { "brightness_pct": 80 }, "target": { "device_id": [ "f0208c60ce4297cc528f81ee33da3a32", "21787f4f32577c124e34685f355021e9", "b76b7a78078cd35dcb7fa1d33cc564d4", "8993ec221435d3072ad1e0cf96b590f8" ] } }, { "delay": { "hours": 0, "minutes": 2, "seconds": 0, "milliseconds": 0 } }, { "service": "light.turn_off", "metadata": {}, "data": {}, "target": { "device_id": [ "f0208c60ce4297cc528f81ee33da3a32", "21787f4f32577c124e34685f355021e9", "b76b7a78078cd35dcb7fa1d33cc564d4", "8993ec221435d3072ad1e0cf96b590f8" ] } } ], "mode": "single" }, "blueprint_inputs": null, "context": { "id": "01HRQ4Z5DH9ZC3VFP0WGYRNT1P", "parent_id": "01HRQ4Z5DHFBQSMMD6305BMM53", "user_id": null } }, "logbookEntries": [ { "name": "Hallway Lights", "message": "triggered", "source": null, "entity_id": "automation.hallway_lights", "context_id": "01HRQ4Z5DH9ZC3VFP0WGYRNT1P", "when": 1710173951.409998, "domain": "automation" }, { "when": 1710173955.67267, "state": "on", "entity_id": "light.hallway_3_hallway_3", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710173955.942411, "state": "on", "entity_id": "light.hallway_2_hallway_2", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710173956.405419, "state": "on", "entity_id": "light.hallway_1_hallway_1", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710173956.850711, "state": "on", "entity_id": "light.hallway_4_hallway_4", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710174079.438744, "state": "off", "entity_id": "light.hallway_3_hallway_3", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710174079.703461, "state": "off", "entity_id": "light.hallway_2_hallway_2", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710174079.969384, "state": "off", "entity_id": "light.hallway_1_hallway_1", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" }, { "when": 1710174080.233714, "state": "off", "entity_id": "light.hallway_4_hallway_4", "context_event_type": "automation_triggered", "context_domain": "automation", "context_name": "Hallway Lights", "context_message": "triggered", "context_entity_id": "automation.hallway_lights" } ] }

Is this what you are looking for? Sorry, I'm new to Home Assistant. However, very excited that there is finally a Dirigera integration

sanjoyg commented 8 months ago

ok I think I know what the issue is. In your automation ur choosing device in the action, instead of that choose entity and choose the light entities. Basically the green button. I have highlighted that with a rectangle.

Screenshot 2024-03-11 at 5 06 58 PM
sanjoyg commented 8 months ago

Let me know if it worked. will close the issue based on that

drunken3agle commented 8 months ago

While it is still not working I would assume for now that it is not an issue with integration, but rather with the automation I set up. Feel free to close the issue. I wont have time to play around with HA for the next little bit.