Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Assistant Connector #3213

Closed
pbathuk opened this issue Jul 9, 2024 · 16 comments · Fixed by #3302
Closed

Home Assistant Connector #3213

pbathuk opened this issue Jul 9, 2024 · 16 comments · Fixed by #3302
Labels
setup issue possibly or definitely an issue with the user setup

Comments

@pbathuk
Copy link

pbathuk commented Jul 9, 2024

Issue

Hi,

I've only recently started using Tandoor, and so far I'm liking it. I've recently tried to setup the connections to my home assistant instance (which I do note says beta) and I and getting some weird issues, so wanted to see if others have the same issue or not?

Intermittent update (tandoor -> HA)

The first issue is that if I add items to my shopping list, sometimes (seems to be if it is a fresh boot of my dockers) it will work, but most of the time I will add things on tandoor and nothing is added to HA. And that is with leaving it for an hour or so as well

no return sync (HA->Tandoor)

Not sure if this is a feature, but if I tick / remove or add in HA to do list tandoor never updates. Again waiting a few hours to see if it was a sync timing issue.

I've managed to setup HA using the rest API route from HA to Tandoor to grab the next meal etc.. so both can "see" each other.

Any help is gratefully received.. as ideally I want to have a single shopping list built (in HA), that my family can use, but if someone adds a meal it will then add the ingredients etc etc.

Thanks

Tandoor Version

1.5.18

OS Version

Ubuntu 24.04

Setup

Docker / Docker-Compose

Reverse Proxy

Nginx Proxy Manager (NPM)

Other

No response

Environment file

# ---------------------------------------------------------------------------
# This template contains only required options.
# Visit the docs to find more https://docs.tandoor.dev/system/configuration/
# ---------------------------------------------------------------------------
# random secret key, use for example `base64 /dev/urandom | head -c50` to gener>
SECRET_KEY=(shhh it's a secret)
# allowed hosts (see documentation), should be set to your hostname(s) but migh>
# ALLOWED_HOSTS=recipes.mydomain.com
# add only a database password if you want to run with the default postgres, ot>
DB_ENGINE=django.db.backends.postgresql
POSTGRES_HOST=db_recipes
POSTGRES_DB=djangodb
POSTGRES_PORT=5432
POSTGRES_USER=djangouser
POSTGRES_PASSWORD=(password)
ALLOWED_HOSTS=tandoor.example.ltd
TZ=Europe/London
DEBUG=1
DISABLE_EXTERNAL_CONNECTORS=0
EXTERNAL_CONNECTORS_QUEUE_SIZE=200
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=465
EMAIL_HOST_USER=(email)
EMAIL_HOST_PASSWORD=(app pass)
EMAIL_USE_TLS=0
EMAIL_USE_SSL=1
DEFAULT_EMAIL_ADDRESSS=(email address)

Docker-Compose file

services:
  db_recipes:
    container_name: db_recipes
    restart: always
    image: postgres:16-alpine
    volumes:
      - ./postgresql:/var/lib/postgresql/data
    env_file:
      - ./.env
    networks:
      - default
  web_recipes:
    container_name: web_recipes
    restart: always
    image: vabene1111/recipes
    env_file:
      - ./.env
    volumes:
      - staticfiles:/opt/recipes/staticfiles
      # Do not make this a bind mount, see https://docs.tandoor.dev/install/doc>
      - nginx_config:/opt/recipes/nginx/conf.d
      - ./mediafiles:/opt/recipes/mediafiles
    depends_on:
      - db_recipes
    networks:
      - default
  nginx_recipes:
    container_name: nginx_recipes
    image: nginx:mainline-alpine
    restart: always
    env_file:
      - ./.env
    depends_on:
      - web_recipes
    volumes:
      # Do not make this a bind mount, see https://docs.tandoor.dev/install/doc>
      - nginx_config:/etc/nginx/conf.d:ro
      - staticfiles:/static:ro
      - ./mediafiles:/media:ro
    networks:
      - default
      - my_bridge
volumes:
  nginx_config:
  staticfiles:
networks:
  my_bridge:
    driver: bridge
    name: my_bridge
    external: true

Relevant logs

(I will grab these later)
@pbathuk pbathuk added the setup issue possibly or definitely an issue with the user setup label Jul 9, 2024
@vabene1111
Copy link
Collaborator

so the sync is one way, so backsync is expected to not work. regarding the other way maybe @mikhail5555 is able to help you debug this.

@mikhail5555
Copy link
Contributor

mikhail5555 commented Jul 10, 2024

Yes I can! The connector should have a decent amount of logging, so could you ping me once you grab the logs?
I personally have been using it for a while and for me it works pretty solid, however the TandoorRecipes container almost never restarts, so might be some slow startup conditions.

Also, I thought about the HA->Tandoor sync, but unless I (or someone) writes a full fetched HA plugin, this wont be possible, and for my use case its also not really required (since i solely use HA for my shopping lists).
I am/was considering to add an 'Delete from tandoor' option to the syncer, but that has quite some implications.

@pbathuk
Copy link
Author

pbathuk commented Jul 10, 2024

_nginx_recipes_logs.txt
_db_recipes_logs.txt
_web_recipes_logs.txt

I've attached some logs from just now.
These have DEBUG=0 - as I see that it says on the admin page to have this turned to 0.

However when I did add a receipe nothing went through to HA at all this time.

When I had DEBUG=1 overnight it worked the 1 way Tandoor -> HA nicely
So wonder if it is the DEBUG flag that is somehow causing the one way sync to fail.

@pbathuk
Copy link
Author

pbathuk commented Jul 10, 2024

On the one way, thanks for explaining.. I was hoping it would automatically mark them as done if in HA.. rather than having to clean up the shopping list in Tandoor seperately - but that is my misunderstanding, so thanks for resolving

@mikhail5555
Copy link
Contributor

thanks for providing the logging, however I am not seeing any of the logs I was expected to see.
I likely will need to do a small PR to enable logging for the application, since currently it seems like its logged into /dev/null

@pbathuk
Copy link
Author

pbathuk commented Jul 10, 2024

Ah sorry about that. Yeah I could not find any log files, so took the ones from the docker containers.
If you can guide me as to how to enable logging, more than happy to do it.

Thanks

@mikhail5555
Copy link
Contributor

Ah sorry about that. Yeah I could not find any log files, so took the ones from the docker containers. If you can guide me as to how to enable logging, more than happy to do it.

Thanks

Not your mistake, it seems I never enabled the logger through Django.

@mikhail5555
Copy link
Contributor

mikhail5555 commented Aug 2, 2024

The extra logging PR got merged, would you be able to change your branch/image to the latest development and add LOG_LEVEL=DEBUG to the your env? (you can keep DEBUG=0)

@mikhail5555
Copy link
Contributor

@pbathuk the latest version has the logging included, if you run into this problem again please enable logging and re-open this issue.
@vabene1111 due to lack of response maybe close this issue?

@vabene1111
Copy link
Collaborator

thanks for keeping an eye on this, closed until we hear any feedback

@pippo73
Copy link
Contributor

pippo73 commented Sep 13, 2024

Hello, as @mikhail5555 asked my I'm back with this problem.
Actually I'm running
Tandoor (HEAD) - 1.5.19 in a docker configuration

Home Assistant
Core 2024.9.1
Supervisor 2024.09.1
Operating System 13.1
Frontend 20240906.0

In my test I've tried to add some items in tandoor, but nothing happened in HA.
If you need any other infos, just me ask what can I do.

Attached you can find the Tandoor conf file and some logs.
Tandoor.zip

@mikhail5555
Copy link
Contributor

mikhail5555 commented Sep 13, 2024

Hello, as @mikhail5555 asked my I'm back with this problem. Actually I'm running Tandoor (HEAD) - 1.5.19 in a docker configuration

Home Assistant Core 2024.9.1 Supervisor 2024.09.1 Operating System 13.1 Frontend 20240906.0

In my test I've tried to add some items in tandoor, but nothing happened in HA. If you need any other infos, just me ask what can I do.

Attached you can find the Tandoor conf file and some logs. Tandoor.zip

Thanks for sharing,
I see a 500 error in the api call to Home assistant. Can you check within home assistant if the error logs there say anything?

Also, it seems the debug log include your bearer token that's used in the request. My bad on that point, but you should likely remove/replace the API key you have currently configured for it.

Edit: Which kind of 'list' are you using, is it a manual created one (aka
image
) aka it can have a description if you click on it:
image
Or is it the 'default' shopping list that comes without description? And if so, can you try creating a new list and set that as a target and try again?

@pippo73
Copy link
Contributor

pippo73 commented Sep 16, 2024

Here are the debug of my HA
tandoor.zip

Also, it seems the debug log include your bearer token that's used in the request. My bad on that point, but you should likely remove/replace the API key you have currently configured for it.

How to do it? could you explain me pls

Which kind of 'list' are you using, is it a manual created one

to do your request I've used the default list
Todo entity : todo.shopping_list

But in previous tests, I've tried to do it also with tandoor specific list.

@mikhail5555
Copy link
Contributor

Here are the debug of my HA tandoor.zip

The error seems to be Entity does not support setting field: description, so could you try again with a tandoor specific list and see if the error persists? the 'default list' does not support descriptions.

How to do it? could you explain me pls

image

@pippo73
Copy link
Contributor

pippo73 commented Sep 16, 2024

Tandoor.zip

good morning :-)

here is the ha log with a fresh new list created now.

@mikhail5555
Copy link
Contributor

Tandoor.zip

good morning :-)

here is the ha log with a fresh new list created now.

Good morning to you too. I am still seeing 500 errors, so could you include your HA logs as well?
Also, maybe its slightly easier to debug on discord, are you in the Tandoor Recipes server by some chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
setup issue possibly or definitely an issue with the user setup
Projects
None yet
4 participants