heston / label-commander

Google Assistant + Raspberry Pi + Dymo LabelWriter = label nirvana!
MIT License
5 stars 0 forks source link

Instructions #12

Open gth001 opened 2 years ago

gth001 commented 2 years ago

Hi - I'd love to make this for my own Dymo, but could you point me to the webhooks info?

I have google assistant and a text ingredient, but I need these for the webhook: URL Method Content type Additional headers Body

Sorry, I've never used firebase, and I didn't see info on REST endpoint or whatever it's called. I did deploy the firebase cloud function, got my API key, installed raspbian and CUPS and dymo drivers on my RPi3b.

Thank you

gth001 commented 2 years ago

Could you screenshot your webhooks (minus any API keys) please?

heston commented 2 years ago

You would get the URL from the Firebase console. You should see your deployed functions on the Functions Dashboard. There will be a table listing the names and URLs.

The method is POST. Content type is application/json. The body is a JSON document like this:

{ "authentication": "AUTHKEY", "items": [ {"body": "{{TextField}}", "qty": 1} ] }

AUTHKEY is taken from functions.config().ifttt.secretkey. This can be set in your Firebase environment.

gth001 commented 2 years ago

I appreciate the help. Is AUTHKEY the same as LC_FIREBASE_API_KEY in env.sh? And is it the same as the string in Project settings > Cloud messaging > Server key ?

Untitled
heston commented 2 years ago

AUTHKEY can be anything. It's unrelated to LC_FIREBASE_API_KEY. I'd recommend using a long (20+ chars) random password here.

It's a pre-shared secret that you send in the POST body so that the cloud function can authenticate the request. Without it, anyone who stumbled upon your endpoint could make your label printer spit out endless labels!

gth001 commented 2 years ago

Thanks, that seems to work. There is still a mysterious "response error", but it's no longer showing secretkey errors. image

Another issue I am running into on the Raspberry Pi is:

raise HTTPError(e, request_object.text)
requests.exceptions.HTTPError: [Errno 404 Client Error: Not Found for url: https://georgelabelcommander.firebaseio.com/print_jobs.json] {
    "error" : "404 Not Found"
}

That URL doesn't seem to exist. If I activate a Realtime Database on the project, I see it does create a https://georgelabelcommander-default-rtdb.firebaseio.com URL but there doesn't appear to be anything at https://georgelabelcommander-default-rtdb.firebaseio.com/print_jobs.json . I don't have an ideas of what to try next.

heston commented 2 years ago

I updated a bunch of things over at https://github.com/heston/label-commander-server, including adding installation instructions in the README. I've verified that I can deploy these functions and they work as expected. Give the updated version a try.

heston commented 2 years ago

Hmm. I'll have to give the RPI client another look over. There may a missing setup step somewhere. My database also doesn't have that key most of the time (since it gets cleared after the print queue is processed).

heston commented 2 years ago

OK, I see what the problem is. Firebase changed the format of the database URL. This PR allows you to set a custom database URL, and also provides more detailed setup instructions. See if you can get things going off that branch.