caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
11.41k stars 404 forks source link

Lametric Time Cloud Mode not working #290

Closed caronc closed 3 years ago

caronc commented 4 years ago

:mega: Notification Service(s) Impacted Lametric Time

:beetle: Describe the bug The device mode works fine but the cloud mode does not. It doesn't appear to have every worked since #235

:bulb: Screenshots and Logs Current output (thanks to @mattpackwood)

$ apprise -vvv -b "Test Message Body" lametric://9403c98d-REDACTED5bd2f@JDEkREDACTED5YVBnMA==
2020-09-03 17:03:29,749 - DEBUG - Loaded LaMetric URL: lametric://9403c98d-REDACTED-246509a5bd2f@JDEka0dTNGdDMREDACTEDN2F5YVBnMA%3D%3D/?mode=cloud&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes
2020-09-03 17:03:29,749 - INFO - Notifying 1 service(s) asynchronous.
2020-09-03 17:03:29,749 - DEBUG - Using selector: EpollSelector
2020-09-03 17:03:29,750 - DEBUG - LaMetric POST URL: https://developer.lametric.com/api/v1/dev/widget/update/com.lametric.9403c98d-REDACTED-246509a5bd2f (cert_verify=True)
2020-09-03 17:03:29,750 - DEBUG - LaMetric Payload: {'frames': [{'icon': 'i620', 'text': 'Test Message Body'}]}
2020-09-03 17:03:30,973 - WARNING - Failed to send LaMetric notification: Page not found., error=404.
2020-09-03 17:03:30,974 - DEBUG - Response Details:
b''

:computer: Your System Details:

:crystal_ball: Additional context n/a

caronc commented 4 years ago

@mattpackwood,

I don't have one of these devices, so it's really hard for me to test this. I spent some time googling how other plugins connected to the Lametric (through the cloud). I made some pretty drastic changes to the app (cloud mode), i'm not sure how it will work... So as far as the cloud mode goes; forget the {client_id} and {secret_id}. It's the {app_id} and {apikey} that is important now.

  1. Sign Up and login to the developer webpage https://developer.lametric.com. Locate your Device API Key; you can find it here: https://developer.lametric.com/user/devices
    1. Create a Notification App if you haven't already done so from: https://developer.lametric.com/applications/sources
    2. Provide it an app name, a description and privacy URL (which can point to anywhere; I set mine to http://localhost). No permissions are required.

The coud URL should look like this (with the new branch only will this work):

# Create a virtual environment to work in
# This way you can just destroy it after when it's all over.
# The below will create a directory called apprise
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch with Lametric chamges
pip install git+https://github.com/caronc/apprise.git@lametric-cloud-support

# Give it a go:
# App ID in the form of a string of numbers and letters
#                    such as 941c51dff3135bd87aa72db9d855dd50
apprise -t "Title" -b "Body" "lametric://{apikey}@{app_id}?mode=cloud"
mattpackwood commented 4 years ago

Hi there,

Errors on install:

(apprise) mattpackwood@ubuntu:~/apprise$ pip install git+https://github.com/caronc/apprise.git@lametric-cloud-support
Collecting git+https://github.com/caronc/apprise.git@lametric-cloud-support
  Cloning https://github.com/caronc/apprise.git (to revision lametric-cloud-support) to /tmp/pip-req-build-pydzbfe1
  Running command git clone -q https://github.com/caronc/apprise.git /tmp/pip-req-build-pydzbfe1
  Running command git checkout -b lametric-cloud-support --track origin/lametric-cloud-support
  Switched to a new branch 'lametric-cloud-support'
  Branch 'lametric-cloud-support' set up to track remote branch 'lametric-cloud-support' from 'origin'.
Collecting PyYAML
  Downloading PyYAML-5.3.1.tar.gz (269 kB)
     |████████████████████████████████| 269 kB 941 kB/s 
Collecting click>=5.0
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting markdown
  Using cached Markdown-3.2.2-py3-none-any.whl (88 kB)
Collecting requests
  Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 206 kB/s 
Collecting requests-oauthlib
  Using cached requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting six
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 1.0 MB/s 
Collecting chardet<4,>=3.0.2
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 2.6 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
     |████████████████████████████████| 156 kB 4.0 MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
     |████████████████████████████████| 127 kB 3.3 MB/s 
Collecting oauthlib>=3.0.0
  Using cached oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
Building wheels for collected packages: apprise, PyYAML
  Building wheel for apprise (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/mattpackwood/apprise/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-pydzbfe1/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-pydzbfe1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-g6megg1y
       cwd: /tmp/pip-req-build-pydzbfe1/
  Complete output (10 lines):
  WARNING: The wheel package is not available.
  WARNING: The wheel package is not available.
  WARNING: The wheel package is not available.
  Warning: 'classifiers' should be a list, got type 'tuple'
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for apprise
  Running setup.py clean for apprise
  Building wheel for PyYAML (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/mattpackwood/apprise/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-j14su5sf/PyYAML/setup.py'"'"'; __file__='"'"'/tmp/pip-install-j14su5sf/PyYAML/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ohjfa1l8
       cwd: /tmp/pip-install-j14su5sf/PyYAML/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for PyYAML
  Running setup.py clean for PyYAML
Failed to build apprise PyYAML
Installing collected packages: PyYAML, click, markdown, idna, chardet, certifi, urllib3, requests, oauthlib, requests-oauthlib, six, apprise
    Running setup.py install for PyYAML ... done
    Running setup.py install for apprise ... done
Successfully installed PyYAML-5.3.1 apprise-0.8.8 certifi-2020.6.20 chardet-3.0.4 click-7.1.2 idna-2.10 markdown-3.2.2 oauthlib-3.1.0 requests-2.24.0 requests-oauthlib-1.3.0 six-1.15.0 urllib3-1.25.10

Ran the code:

apprise -vvv -t "Title" -b "Body" "lametric://9a7affc30b2REDACTED35ae350fc8c5f98ada@9403c98d-REDACTEDa5bd2f?mode=cloud"
2020-09-05 09:04:48,871 - DEBUG - Loaded LaMetric URL: lametric://9a7affc30b22b3e8a15REDACTEDd1d2af5035ae350fc8c5f98ada@9403c98d-98aa-2REDACTED09a5bd2f/?mode=cloud&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes
2020-09-05 09:04:48,871 - INFO - Notifying 1 service(s) asynchronous.
2020-09-05 09:04:48,871 - DEBUG - Using selector: EpollSelector
2020-09-05 09:04:48,872 - DEBUG - LaMetric POST URL: https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.9a7affc3REDACTED5d9f8fb2d1d2af5035ae350fc8c5f98ada (cert_verify=True)
2020-09-05 09:04:48,872 - DEBUG - LaMetric Payload: {'frames': [{'icon': 'i620', 'text': 'Title\r\nBody'}]}
2020-09-05 09:04:49,740 - WARNING - Failed to send LaMetric notification: error=403.
2020-09-05 09:04:49,741 - DEBUG - Response Details:
b'{"error":{"code":null,"message":"Forbidden","trace":["Permissions denied"]}}'

I added the -vvv as I did not see any message from the "first try".... If you like I am happy to send you (in a secure method) the unredacted version of my credentials (I can always reset them later).

caronc commented 3 years ago

I made some more changes; they may or may not work. You'll have to do a git update to pull the new changes in.

I would like to take you up on your offer if this doesn't work though. Perhaps you could email me (at lead2gold@gmail.com) your App ID an API Key if this fails? I won't spam your account, i just want to get the 200 response code letting me know i'm at least pushing the updates properly.

Who knows though; maybe the latest code will work... same rules apply as before though; format it as: lametric://{apikey}@{app_id} :slightly_smiling_face:

caronc commented 3 years ago

@mattpackwood Thank you for reaching out to me. You provided the {app_id} in your email (which is great), i just need your Device {apikey} so we can construct : lametric://{apikey}@{app_id}?mode=cloud

I've pushed some big changes and also a lot of unit-tests to go with it; so it's possible the latest code works too.

Thanks for all your help so far! :slightly_smiling_face: :+1:

mattpackwood commented 3 years ago

Chris,

This is what I get at my end…

(apprise) mattpackwood@ubuntu:~/apprise$ apprise -vvv -t "Title" -b "Body" "lametric://9a7affc30b22b3e8a151e034b81b855d9f8fb2d1d2af5035ae350fc8c5f98ada@9403c98d-98aa-2e6e-58ff-246509a5bd2f?mode=cloud" 2020-09-10 10:26:22,058 - DEBUG - Loaded LaMetric URL: lametric://9a7affc30b22b3e8a151e034b81b855d9f8fb2d1d2af5035ae350fc8c5f98ada@9403c98d-98aa-2e6e-58ff-246509a5bd2f/?mode=cloud&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes 2020-09-10 10:26:22,058 - INFO - Notifying 1 service(s) asynchronous. 2020-09-10 10:26:22,058 - DEBUG - Using selector: EpollSelector 2020-09-10 10:26:22,059 - DEBUG - LaMetric POST URL: https://developer.lametric.com/api/v1/dev/widget/update/com.lametric.9403c98d-98aa-2e6e-58ff-246509a5bd2f (cert_verify=True) 2020-09-10 10:26:22,059 - DEBUG - LaMetric Payload: {'frames': [{'icon': 'i620', 'text': 'Title\r\nBody'}]} 2020-09-10 10:26:22,943 - WARNING - Failed to send LaMetric notification: Page not found., error=404. 2020-09-10 10:26:22,944 - DEBUG - Response Details: b''

Matt

Matt Packwood E-mail: mattpackwood@gmail.com Mobile / iMessage: +1-248-346-2166 Skype: mattpackwood@msn.com

On Sep 9, 2020, at 7:02 PM, Chris Caron notifications@github.com wrote:

@mattpackwood https://github.com/mattpackwood Thank you for reaching out to me. You provided the {app_id} in your email (which is great), i just need your Device {apikey} so we can construct : lametric://{apikey}@{app_id}?mode=cloud

I've pushed some big changes and also a lot of unit-tests to go with it; so it's possible the latest code works too.

Thanks for all your help so far! 🙂 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/caronc/apprise/issues/290#issuecomment-689867953, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIL52ALEIFG7P6BL37VJYLSFACR5ANCNFSM4QYZIA2A.

caronc commented 3 years ago

Thanks Matt,

I reached out to Lametric Time support; their documentation is all over the map. It's really hard to follow how to do things with the cloud pushing. They got back to me and said that it won't work with a Notification App. Instead you have to make an Indicator App; see here: https://lametric-documentation.readthedocs.io/en/latest/guides/first-steps/first-lametric-indicator-app.html

This is why we're having a hard time identifying what the Application ID is... the Notification App won't provide us one.

Once you create an Indicator App, the page will provide you a URL that looks like this:

... only that it doesn't.... the instructions on the official website linked to above creates an Indicator App, but only gives you a local 'Push URL' you can use (after you click on that option when creating the App) that looks like this:

First off, in the example they provide, the word widget is spelled wrong witget wrong in the URL (it looks like the one above), and they no longer provide a remote URL example like Google turns up for me that you can do.

I've reached out and asked if we can just substitute the APP_ID in the local push for the remote and have it work (i haven't heard back yet). It doesn't make sense to add support for the Local App Notifications since just pushing directly to the device (the mode already supported) offers WAY more options. You lose out on a lot of extra features when you use the Indicator App payload options.

I'll keep you posted.. In the meantime, if you want to try generating a Indicator App and set it to 'Local Push', (the only Push option) and share with me the details it might work! Or you can actually try it out for yourself if you like too! :slightly_smiling_face:

Chris

mattpackwood commented 3 years ago

Chris,

I think I know what the “issue” is…

Looking at the instructions it looks like these are pull, not push notifications…

You can push within a LAN and you can poll a remote server, but I do not see a way to generate a push form outside the LAN…

Matt

caronc commented 3 years ago

@mattpackwood i agree; that's the way it appears now, but the screenshots from their website paint a different picture. They show that it used to provide both URLs (for cloud pushing) and there are a lot of sources they still link to that use this technique (so while it appears to be suddenly hidden, it's very much working). See:

When i hear back from LaMetric, i'll let you know. There is a good chance if you create an Indicator App and configure it for a Local Push just to get the APP ID (from the end of the URL), it might work when paired with your API Key (from the device list screen).

mattpackwood commented 3 years ago

@caronc I just e-mailed you the credentials I got from creating an indicator app...

caronc commented 3 years ago

Thanks a lot Matt! It looks like the APP Access Token isn't universal :slightly_frowning_face:. I get the error from their remote server:

Using the latest code I pushed:

apprise -vvv -b test "lametric://{APP_ACCESS_TOKEN}@{APP_ID}/1?mode=cloud"

Produced...

2020-09-10 15:20:37,744 - DEBUG - Loaded LaMetric URL: lametric://{APP_ACCESS_TOKEN}@{APP_ID}/1/?mode=cloud&format=text&overflow=upstream&rto=4.0&cto=4.0&verify=yes
2020-09-10 15:20:37,744 - INFO - Notifying 1 service(s) asynchronous.
2020-09-10 15:20:37,744 - DEBUG - Using selector: EpollSelector
2020-09-10 15:20:37,745 - DEBUG - LaMetric POST URL: https://developer.lametric.com/api/v1/dev/widget/update/com.lametric.{APP_ID}/1 (cert_verify=True)
2020-09-10 15:20:37,745 - DEBUG - LaMetric Payload: {'frames': [{'icon': 'i620', 'text': 'test'}]}
2020-09-10 15:20:38,545 - WARNING - Failed to send LaMetric notification: error=403.
2020-09-10 15:20:38,546 - DEBUG - Response Details:
b'{"error":{"code":null,"message":"Forbidden","trace":["Only local pushes are allowed for this application"]}}'

Edit: The Lametric Tutorial explaining how all this works mentions Publishing your app. Maybe this needs to be done first before you can perform a remote post? Maybe there is some way you can perform this publishing?

mattpackwood commented 3 years ago

Yep, I get the feeling that this is a "local only" service like the desktop notify. Pity, having a cloud-aware device that does not accept pushes is pity...

caronc commented 3 years ago

@mattpackwood try opening up your App again (on the Lametric Website) and click on the Draft Tab. You should be able to Publish the app which would make it available (for others i believe too) and you can then post to it with perhaps a new Access Token it generates (or it might just make the one you already have work).

mattpackwood commented 3 years ago

Chris, it looks like the website is smart enough to say that a local push application can only be set to "Private".

caronc commented 3 years ago

Matt,

Would you be okay with making your App public (for publishing/remote access purposes); you can always delete it later. Keep in mind that no one will abuse it because you're also the only one who can post to it (as no one else has the Access Token). But if you're not comfortable with that, I totally understand! You've been a fantastic help regardless even just to get to this point! :slightly_smiling_face:

I'll still probably merge all my new changes on this new Lametric branch just because of the improvements that did come with it regardless.

mattpackwood commented 3 years ago

Chris,

I have published it, the problem seems to be that: If you create an Indicator App that does not have an APP_ID

I just e-mailed you some info...

Matt

caronc commented 3 years ago

Thanks Matt,

I'm merging all of my changes and closing off this issue now. If you have the ability to use the developer.api now; you will be able to use the cloud mode at this time. LaMetric has definitely changed things around making this process different then what they've officially documented here. So it's anyone's guess how new users can get access to this mode again.

I reached out to them through their support and haven't heard back.

For now I'm closing this issue off because it's about the best it's going to get. If LaMetric updates their documentation or opens up the possibility to use the legacy developer.api code, then the new code pushed in the Pull Request associated with this ticket will work.