Open mf244 opened 1 week ago
Thanks for the request and suggested code. I suspect ChatGPT is not aware that the integration makes exclusive use of the python-o365 library to access the graph api - https://github.com/O365/python-o365. It might be worth acquainting yourself with that.
I would suspect that all the ToDo information you are looking to filter on is already present in the attributes of the existing todo entity, so you can write a filter within HA to extract what you want. That said I'm not sure if you can create a template todo entity.
At the moment that query pulls everything, whilst you should really only pull what is needed from the api. The library I linked supports the filtering that the graph API supports. So it would be useful to have an example that uses a filter for importance and due date directly against the graph API, rather than post processing it.
I'm buried in other stuff at the moment and away for a couple of weeks, so this won't get looked at until December some time.
Thanks for the info!
I do not yet possess the skills to just merge anything in, but will definitely start learning how stuff works. I'll rtfm and whatnot and see what I can do.
No rush on anything on your end. It would just be nice to have eventually.
I'll see if I can bang some rocks together until something sparks
Thanks, Matt
If you can create the example api queries with the filters that would help substantially just a case of googling examples and then trying queries in ms graph explorer. It’s only what I would have to do.
Hello!
First of all, thank you for all your work on this! I love this integration, but it would be really great if it could pull a list of tasks into home assistant based off of importance or due date.
I have made a proof of concept (mostly ChatGPT) that uses the graph API to pull all tasks and return un-completed important or due today tasks. Please find attached the files that make it happen. You will need to add a credentials.json if you wish to run it yourself.
Pastebin Proof Of Concept main.py: https://pastebin.com/7qVELW5R Pastebin Proof Of Concept auth.py: https://pastebin.com/nckLwEYN
Here is ChatGPT's explanation of how to add these features (not to homeassistant, but i'm sure the code will fit in)
Code Addition for Important Tasks In your main function or where you handle task retrieval, add the following code to filter for tasks marked as "Important."
This snippet creates a list of important tasks by checking if importance is set to "high".
Code Addition for Due Today Tasks First, get today’s date in the correct format. Then, filter tasks by comparing each task’s dueDateTime with today’s date.
Summary of Changes Important Tasks: Added a filter based on the importance property to retrieve tasks marked as "Important." Due Today Tasks: Added a filter using dueDateTime to retrieve tasks due today.
I hope this can be added in to the mainline, as it would significantly improve my life. The proof of concept script attached successfully returns the correct tasks, and it just needs to be added as a list into home assistant.
Please let me know if you need anything from me (or ChatGPT). Thank you for all your hard work on this integration!