JanGiese / notion_todo

ToDo Integration for Notion and HomeAssistant
MIT License
11 stars 3 forks source link

unable to connect to server #24

Open marcsauter75 opened 4 months ago

marcsauter75 commented 4 months ago

System Health details

Hi, i tried to integrate this cool idea. But I always get unable to conenct server ? Do you have some more detailed information about database ID creating and token. Or is this not working anymore with newest HA versions ?

Checklist

Describe the issue

Unable to connect to the server.

Reproduction steps

  1. create task list from template choosed DB ID from brower
  2. create a internal and a publc token - both not working
  3. ...

Debug logs

do not have logs

Diagnostics dump

No response

JanGiese commented 4 months ago

Hey there, It looks like the integration has indeed a problem with either the latest HomeAssistant version or an update to the Notion API, My Tasks are fetched, but I am unable to update them. Guess it´s a similar when setting up the integration. I will look into it today and get back to you.

JanGiese commented 4 months ago

Hey, I have created a new Release V1.1.1, which should fix all issues introduced with the latest updates. If it is not working on your side with this version, you can verify your token and database is using e.g. curl:

curl --location --request POST 'https://api.notion.com/v1/databases/<database-id>/query' \
--header 'Authorization: Bearer <token>' \
--header 'Notion-Version: 2022-02-22' 

This should give you a hint, if either the token or the database id is wrong. The database id is easy to get, just copy the link to the database from notion, e.g. https://www.notion.so/<database-id>?v=<view-id>&pvs=4

The token generation is a bit more complex, but well described in the Notion Documentation. Then the token must be authorized to access the new database via Notion (in my case it is called Python):

image
marcsauter75 commented 4 months ago

Fantastic, will test it the next days...

marcsauter75 commented 4 months ago

Hi, seems to connect now. I can see the entity in the services but can not use it in lovelace todo How will it be integrated in lovelace ? "Entity is not available"

marcsauter75 commented 4 months ago

that is info from logfile Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 261, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 417, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners update_callback() File "/config/custom_components/notion_todo/todo.py", line 79, in _handle_coordinator_update self._status[id] = propHelper.get_property_by_id(TASK_STATUS_PROPERTY, task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/notion_todo/notion_property_helper.py", line 14, in get_property_by_id return NotionPropertyHelper._property(data['properties'][key])


KeyError: None
bjornskov commented 3 months ago

Seems like I have a similar issue. I can't create the entity either. However my error message looks like this: `Error adding entity todo.notion for domain todo with platform notion_todo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 576, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 865, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1327, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/notion_todo/todo.py", line 126, in async_added_to_hass self._handle_coordinator_update() File "/config/custom_components/notion_todo/todo.py", line 79, in _handle_coordinator_update self._status[id] = propHelper.get_property_by_id(TASK_STATUS_PROPERTY, task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/notion_todo/notion_property_helper.py", line 14, in get_property_by_id return NotionPropertyHelper._property(data['properties'][key])


KeyError: None`
kforeverisback commented 2 months ago

Same error msg here. I did a debug log and the task object at todo.py@L79 looks like this

{
  "object": "page",
  "id": "xxxxxxxx-yyyy-yyyy-yyyy-134456750f9f0",
  "created_time": "2024-05-04T06:04:00.000Z",
  "last_edited_time": "2024-05-04T06:04:00.000Z",
  "created_by": {
    "object": "user",
    "id": "xxxxxxxx-yyyy-yyyy-yyyy-134456750f9f0"
  },
  "last_edited_by": {
    "object": "user",
    "id": "xxxxxxxx-yyyy-yyyy-yyyy-134456750f9f0"
  },
  "cover": null,
  "icon": { "type": "emoji", "emoji": "🔨" },
  "parent": {
    "type": "database_id",
    "database_id": "xxxxxxxx-yyyy-yyyy-yyyy-134456750f9f0"
  },
  "archived": false,
  "in_trash": false,
  "properties": {
    "Due": {
      "id": "%3B%3A%7Dz",
      "type": "date",
      "date": { "start": "2022-11-08", "end": null, "time_zone": null }
    },
    "Assign": {
      "id": "IrEw",
      "type": "people",
      "people": [
        { "object": "user", "id": "xxxxxxxx-yyyy-yyyy-yyyy-134456750f9f0" }
      ]
    },
    "Status": {
      "id": "Yz%7Cr",
      "type": "status",
      "status": {
        "id": "xxxxxxxx-yyyy-yyyy-yyyy-134456750f9f0",
        "name": "Done",
        "color": "green"
      }
    },
    "Task name": {
      "id": "title",
      "type": "title",
      "title": [
        {
          "type": "text",
          "text": { "content": "Build Admin console", "link": null },
          "annotations": {
            "bold": false,
            "italic": false,
            "strikethrough": false,
            "underline": false,
            "code": false,
            "color": "default"
          },
          "plain_text": "Build Admin console",
          "href": null
        }
      ]
    }
  },
  "url": "https://www.notion.so/Build-Admin-console-XXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "public_url": "null"
}

It doesn't seem to have notion%3A%2F%2Ftasks%2Fstatus_property (const.TASK_STATUS_PROPERTY) as ID under its properties, hence it's failing the function.

IEuphemia commented 1 month ago

Any fix for this? I got the same error.