Dryer Done piston NotifyMe "unauthorized" [Solved]


#1

1) Give a description of the problem

Just trying a simple piston to call the NotifyMe API on a simple trigger, in this case when the HomeSeer HS-FS100-L indicator light sensor sees the light go out (“Button #1”) on my dumb dryer. I’ve copied a sample piston from a single-post member, and no matter how I try to do it, it comes back as "unauthorized – even though curl from a SHell works properly with the same credentials. Note that I’m a rank newbie not just on the forum, but scripting as well. I’m reading all I can, and trying to wrack my addled AARP brain to rattle what’s left in there to learn logic and syntax. It’s new to me, but not so foreign that I can’t learn as I go. I appreciate any and all help and will mark solved for sure!

ETA: I should note I also defined the string as a constant and that had no bearing of course.
ETA 2: the error in the log is truncated here, but it reads " +190ms ║║Error executing external web request: groovyx.net.http.HttpResponseException: Unauthorized"

2) What is the expected behaviour?

Trigger should action a Post call to the NotifyMe URI.

3) What is happening/not happening?

Nothing happens, see log below for the “unauthorized” line.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full

8/23/2020, 1:53:23 PM +976ms
+1ms ╔Received event [Dryer].button = pushed with a delay of 33ms
+48ms ║RunTime Analysis CS > 14ms > PS > 20ms > PE > 14ms > CE
+50ms ║Runtime (39074 bytes) successfully initialized in 20ms (v0.3.110.20191009) (48ms)
+51ms ║╔Execution stage started
+58ms ║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+60ms ║║Cancelling condition #2's schedules...
+60ms ║║Condition #2 evaluated true (5ms)
+61ms ║║Cancelling condition #1's schedules...
+62ms ║║Condition group #1 evaluated true (state changed) (7ms)
+64ms ║║Cancelling statement #4's schedules...
+73ms ║║Sending external web request to: api.notifymyecho.com/v1/NotifyMe
+190ms ║║Error executing external web request: groovyx.net.http.HttpResponseException: Unauthorized
+191ms ║║Executed virtual command httpRequest (118ms)
+193ms ║╚Execution stage complete. (142ms)
+194ms ╚Event processed successfully (194ms)

ETA: If anybody somehow landed here searching for keywords with a similar issue, please follow along after the solution post (#2) to get the same clarification I needed. Also note the second issue I inadvertently discovered: don’t trust your computer or device’s copy-paste from an email or other source, and use a proper text editor to clean it up and make sure the formatting is correct! Hope @guxdude’s solution and @WCmore’s clarifications help somebody else.


#2

What I did was create a global variable like this:

The contents equate to:

@URLNotifyMe=https://api.notifymyecho.com/v1/NotifyMe?accessCode=<MY ACCESS CODE&notification=

Then from any piston I can use the following

String message=“My notify me message”

Then

make GET request to {@URLNotifyMe message}

Just enter the two strings as an expression and you’re all set. No need to add any authorization or variables as it is all in the URL. Key is including the '&notification=" at the end of the URL string so all you need to do is append your message. Hope this helps.


#3

Oh wow cool. I’ll get to work on it after supper and let you know. Thanks for the hints.


#4

No luck. Again, I’m not sure I understand everything when its streamlined like in your post, but when I enter it with any combination of using Values or Expressions, it throws an error calling the URL.

8/23/2020, 6:32:14 PM +420ms
+1ms ╔Received event [Dryer].button = pushed with a delay of 43ms
+66ms ║RunTime Analysis CS &gt; 20ms &gt; PS &gt; 22ms &gt; PE &gt; 24ms &gt; CE
+69ms ║Runtime (37506 bytes) successfully initialized in 22ms (v0.3.110.20191009) (67ms)
+70ms ║╔Execution stage started
+77ms ║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+78ms ║║Cancelling condition #2's schedules...
+79ms ║║Condition #2 evaluated true (5ms)
+80ms ║║Cancelling condition #1's schedules...
+81ms ║║Condition group #1 evaluated true (state changed) (8ms)
+83ms ║║Cancelling statement #3's schedules...
+92ms ║║Sending external web request to: api.notifymyecho.com/v1/NotifyMe?accessCode=amzn1.ask.account.AEE5T2[truncated]7QDH**MHI¬ification=**
+93ms ║║Error executing external web request: java.lang.reflect.UndeclaredThrowableException
+95ms ║║Executed virtual command httpRequest (6ms)
+97ms ║╚Execution stage complete. (28ms)
+98ms ╚Event processed successfully (98ms)

“Error executing external web request: java.lang.reflect.UndeclaredThrowableException


#5

Did you censor the “not” in front of “ification”???

Also, did you add a string at the end (after the equal sign) as the message?


#6

I did not but I noticed that in the log as well. I double checked the global variable when I saw it and it’s correct. Not sure what that is.

ETA where should I put the string that fills in the space after the “=“? I assumed in the script that “string message” would just dump it after the get.


#7


#8

I would drop the “query data”, and try an expression, as @guxdude mentioned… IE:

pic

which ends up looking like this:

pic


#9

On it. Will let you both know. You do realize how green I am? :grin:


#10

It’s OK… We have people here with all levels of skills…


#11

OK! I did two things: first I copied the access code from the NotifyMe activation email again and dropped it in a proper text editor to make sure there isn’t a hidden line break; then, I modified the Get to dump the “message” string as you suggested. As you’ve already guessed, it worked! As you can see, I learn quickly: I knew that that hidden formatting error would get me and make the bug hunt drive me bonkers. :smiley:

Now the dirty part: I feel @guxdude’s post is what got me pointed here, I just couldn’t parse his streamlined instructions. If I edit my OP to point other newbs to read the posts after his solution, would that be proper etiquette?


#12

I’m also quickly catching on that webCoRE is quite a bit more format-agnostic than I expected!:+1:t3:


#13

I agree. He definitely deserves the solution2


Sure thing. It may help someone else…


#14

Awesome. I think it may. Thanks a bunch for your patient help as well. Dang quick, too, both of you!


#15

Sorry I stepped away but glad @WCmore could walk you though it. just as there are people with all skill levels here, there are plenty of people willing to jump in and help.