Change line of code in homeassistant/components/todoist/calendar.py

Hey @nickrout

If you get a chance to have a look. This is what I’m trying to do.

So the todoist integration is broken again (not in breaking changes) and has been fixed but god knows when the PR will come through.

So from what I’ve been told here;

This needs to change, but I cant get into the container to edit the one line in this file :frowning:

index c3e8f61fcc..ea5aab1534 100644
--- a/homeassistant/components/todoist/calendar.py
+++ b/homeassistant/components/todoist/calendar.py
@@ -446,7 +446,7 @@ class TodoistProjectData:
             LABELS: [],
             OVERDUE: False,
             PRIORITY: data.priority,
-            START: dt.utcnow(),
+            START: dt.now(),
             SUMMARY: data.content,
         }

Sorry for the delay in replying.

Easiest and best way is to turn the integration into a custom component.

I take it from the earlier thread you have HASS OS.

SSH

If you haven’t installed the SSH & Web Terminal addon, do so and turn off protection mode.

Enter the homeassistant docker container

In the terminal window, or ssh’d in to HA, run

docker exec -it homeassistant /bin/bash

Copy the integration code out

Find the integration code

find / |grep components/todoist

This will find you the path to the source. Say it is /usr/src/homesassistant/components/todoist

Copy the source to custom_components

cp  -R /usr/src/homesassistant/components/todoist /config/custom_components

Exit the home assistant container

exit

You are now back in the normal SSH container
Edit your file

nano -w /config/custom_components/todoist/calendar.py

Ctrl-X to exit
Edit the manifest file to include a version key

nano -w /config/custom_components/todoist/manifest.json

Add a version key or the component won’t be recognised. Note the comma , at the end of the line

{
  "domain": "todoist",
  "name": "Todoist",
  "codeowners": ["@boralyl"],
  "documentation": "https://www.home-assistant.io/integrations/todoist",
  "iot_class": "cloud_polling",
  "loggers": ["todoist"],
  "version": "99.9",   <---add this line
  "requirements": ["todoist-api-python==2.0.2"]
}

Restart home assistant.

The custom version, with your edit, should now be used. Check your log to make sure it is.

Hey mate,

Thank you so much for taking the time do lay all this out. Haven’t had a chance to do this yet, but thanks for taking the time. Ill let you know how I go with it in the next day or so :slight_smile:

1 Like

Ok, Ive done that, nothing changed. What am I looking for to see that custom_componets copied it over?

I have two logs;

2023-04-18 16:59:58.982 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration todoist which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

Its the above?

2023-04-18 17:01:15.841 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=todoist, service=new_task>

Yes

Maybe the fix you thought was right isn’t right. Welcome to software development.

That would be confirmed by the latest GitHub post. Do as the man says and copy the calendar.py with all the fixes.

I thought (SyncWorker_0) seems like it would be something that copied a custom component over, but just it doesn’t look like its done it.

So I just copied the file from the docker to /config and compared the two and it seems to be the old one.

Let me check your instructions to see I missed anything?

Logged into the docker and found the component folder.

Copied it to the custom_componenets folder

Copied the raw file from github as suggested and pasted into the existing calender.py

Add the version number to the JSON

image

Restart HA

Not profiting lol

EDIT I seem to have bigger problems, I’m not getting a UI now.

The only thing I can think of is that I left the calender.py in the config folder and or didnt exit the docker bin bash before I restarted.

Anyway, ill get back to you when I got it fixed lol

EDIT Yeah, don’t leave a .py file in your config folder LOL, moving on :wink:

So its not copying across. Also file structure looks a little different. Sorry this is dragging on lol really appreciate you helping out. The only thing I can see here is the file structure is a little different from what you originally specified. I have no idea if that’s important though.

If you get a chance, let me know what you think :slight_smile:

/usr/src/homeassistant/homeassistant/components/todoist/__init__.py
/usr/src/homeassistant/homeassistant/components/todoist/types.py
/usr/src/homeassistant/homeassistant/components/todoist/calendar.py
/usr/src/homeassistant/homeassistant/components/todoist/services.yaml
/usr/src/homeassistant/homeassistant/components/todoist/manifest.json
/usr/src/homeassistant/homeassistant/components/todoist/const.py
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/coordinator.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/types.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/__init__.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/calendar.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/const.cpython-310.pyc
/config/custom_components/todoist
/config/custom_components/todoist/coordinator.py
/config/custom_components/todoist/__init__.py
/config/custom_components/todoist/types.py
/config/custom_components/todoist/calendar.py
/config/custom_components/todoist/services.yaml
/config/custom_components/todoist/manifest.json
/config/custom_components/todoist/const.py
/config/custom_components/todoist/__pycache__
/config/custom_components/todoist/__pycache__/coordinator.cpython-310.pyc
/config/custom_components/todoist/__pycache__/types.cpython-310.pyc
/config/custom_components/todoist/__pycache__/__init__.cpython-310.pyc
/config/custom_components/todoist/__pycache__/calendar.cpython-310.pyc
/config/custom_components/todoist/__pycache__/const.cpython-310.pyc

It looks like you might have copied all the files from the dev branch’s todoist integration into your custom component’s todoist folder. If so that’s good, that means you are up to date. If not, make sure you do that.

If you still are not seeing a calendar in the on state that you expect, go to the services tab and run the service Home Assistant Core Integration: Update entity and specify the calendar entity and hit the Call Service button. Then go back to the states tab and report back if it’s still not on as expected.

It’s plausible there is some other bug, but it’s hard to say without knowing your exact environment setup.

Also, it’s not clear what version of HA you are running, from the file structure you have above, it doesn’t look like you are running a verison >= 2023.04, since coordinator.py was added in that release.

Well spotted. No wonder it hasn’t worked.

Thanks Aaron,

Definitely up to date;

Home Assistant 2023.4.5
Supervisor 2023.04.0
Operating System 10.0
Frontend 20230411.1 - latest

All the files in custom_components came from the todoist folder. The only thing I copied from GitHub was calendar.py

Sorry, I was just trying to show the file structure homeassistant/homeassistant/ that I was confused about lol. Here is the full thing if that helps :slight_smile: Do you want me to try downloading everything from

The only thing that’s been updated recently is calendar.py… But let me what you need? :slight_smile:

bash-5.1# find / |grep components/todoist                                                                                     
find: /proc/66/task/137/fd/48: No such file or directory
/usr/src/homeassistant/homeassistant/components/todoist/usr/src/homeassistant/homeassistant/components/todoist/coordinator.py
/usr/src/homeassistant/homeassistant/components/todoist/__init__.py/usr/src/homeassistant/homeassistant/components/todoist/types.py/usr/src/homeassistant/homeassistant/components/todoist/calendar.py
/usr/src/homeassistant/homeassistant/components/todoist/services.yaml
/usr/src/homeassistant/homeassistant/components/todoist/manifest.json
/usr/src/homeassistant/homeassistant/components/todoist/const.py/usr/src/homeassistant/homeassistant/components/todoist/__pycache__
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/coordinator.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/types.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/__init__.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/calendar.cpython-310.pyc
/usr/src/homeassistant/homeassistant/components/todoist/__pycache__/const.cpython-310.pyc
/config/custom_components/todoist
/config/custom_components/todoist/coordinator.py
/config/custom_components/todoist/__init__.py
/config/custom_components/todoist/types.py
/config/custom_components/todoist/calendar.py
/config/custom_components/todoist/services.yaml
/config/custom_components/todoist/manifest.json
/config/custom_components/todoist/const.py
/config/custom_components/todoist/__pycache__
/config/custom_components/todoist/__pycache__/coordinator.cpython-310.pyc
/config/custom_components/todoist/__pycache__/types.cpython-310.pyc
/config/custom_components/todoist/__pycache__/__init__.cpython-310.pyc
/config/custom_components/todoist/__pycache__/calendar.cpython-310.pyc
/config/custom_components/todoist/__pycache__/const.cpython-310.pyc

The formatting is a bit weird on that, so a screen shot as well LOL

Ok, that last screenshot lines up with what I would expect in making sure you are running >= 2023.04. Assuming you downloaded the raw file for calendar.py from github and put it in /config/custom_components/todoist/, that should be all that is needed (after a restart).

Did you happen to try manually updating the entity to see if it changed it’s status to what you expected? If not, follow the instructions in my previous comment and report back.

You’ll have to forgive me, it looks like I introduced a bug in 2023.4.1 when adding the data coordinator. I don’t use the todoist integration personally, only while testing during development. I just noticed after waiting for a period of time that the states of the calendars weren’t updating. It looks like they will only update if you manually update them via the homeassitant.update_entity service.

I’ve created an issue so I can look into a fix: Todoist data update coordinator is not updating task data. · Issue #91780 · home-assistant/core · GitHub

No worries mate, thanks for working on it especially if your not even using it, its appreciated :slight_smile:

So using the manual update, it works :slight_smile:

Let me know if you need someone to do further testing :slight_smile:

At least with this workaround I can finish my to do list eink display, so thanks :slight_smile:

I’m glad to know the other fix does indeed work for you!