Hopefully plugin related?

Posted on
Fri Feb 25, 2022 8:11 pm
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Hopefully plugin related?

I'm trying to access a page that every script I've written either does nothing or I get an SSL certificate error.

I am playing an Alexa Routine Trigger URL.
https://www.amazon.com/Virtual-Smart-Ho ... 104&sr=1-2

Once I create a fake "doorbell", I can trigger it in alexa by loading a webpage. Each fake "doorbell" device gives me 3 web address to use
Code: Select all
HTML Response: https://www.virtualsmarthome.xyz/url_routine_trigger/activate.php?trigger=1234_substiute_for_my_trigger&token=4321_substitute_for_my_token&response=html
XML Response: https://www.virtualsmarthome.xyz/url_routine_trigger/activate.php?trigger=1234_substiute_for_my_trigger&token=4321_substitute_for_my_token&response=xml
JSON Response: https://www.virtualsmarthome.xyz/url_routine_trigger/activate.php?trigger=1234_substiute_for_my_trigger&token=4321_substitute_for_my_token&response=json
The literature on the site says you can use http (no S), if you have problems, but with the scripts I tried without the s, the script ran, but nothing happened.

Tonight I tried setting it up as a GhostXML Device (Real Type). Feed JSON, Manual Refresh. Past that point, I've not sure. bearer has gotten me the closest to success "GUI turns green" but no data is parsed (which I don't care about), and the alexa device on the other end doesn't respond (which I do care about).

I'm not sure if your plugin is the solution to my problem or if I have to figure out a scripting solution. I'm drawing a blank across the board.

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 6:21 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

What happens when you enter these URLs in a browser?

What version of MacOS are you using?

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 26, 2022 7:23 am
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Re: Hopefully plugin related?

High Sierra (10.13.6)

If I put the JSON version in a browser, it returns with:
Code: Select all
{ "URLRoutineTrigger": { "triggerId": "d1f2c2a5-0bc3-41f3-ac9c-cd3e6b8ca66c", "triggerName": "Access\u0020Control", "userName": "Bill\u0020Moore", "triggerActivationStatus": "success" } }


If I put the XML version in a browser, it returns with:
Code: Select all
d1f2c2a5-0bc3-41f3-ac9c-cd3e6b8ca66c Access Control Bill Moore success


That, in turn, fires an alexa routine which reads an indigo variable. So I can tell if it's working because I'll hear the variable spoken by alexa and see
Code: Select all
Feb 26, 2022 at 7:14:52 AM
   Alexa                           request the value of variable 'my_message'
in my log.

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 7:51 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

It looks like the JSON link is returning valid JSON (I didn't test it). It looks like the XML link is NOT returning valid XML (at least from what you posted). Valid XML would look something akin to this:

Code: Select all
...
<DevicesConnectedChannel2>1</DevicesConnectedChannel2>
<DevicesConnectedChannel3>1</DevicesConnectedChannel3>
<DataErrorsChannel1>4</DataErrorsChannel1>
<DataErrorsChannel2>7</DataErrorsChannel2>
<DataErrorsChannel3>24</DataErrorsChannel3>
<VoltageChannel1>4.97</VoltageChannel1>
<VoltageChannel2>4.97</VoltageChannel2>
<VoltageChannel3>4.97</VoltageChannel3>
...
It sounds like when you enter the URLs in the browser, Alexa responds with the actions you expect.

The GhostXML plugin works with both http:// and https:// links, so I don't think that's the problem. String type vs Real type shouldn't make a difference with anything except how the return values are processed. As far as I know, High Sierra should still support updated SSL implementations, so I don't think that's the problem. Be sure to set the authentication method to `None` if you don't need to enter a username/password or API token as a part of the call.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 26, 2022 8:30 am
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Re: Hopefully plugin related?

There is an API token.

The URL pattern is
url.php?trigger=TRIGGERID&token=TOKENID&response=json

From the debug log, it looks like it might be cutting of the URL after the "&" which would strip out the part that identifies the response type. Could that be it?
Code: Select all
GhostXML Debug                  [My Message] curl error /bin/sh: -H: command not found *   Trying 93.90.176.11... * TCP_NODELAY set * Connected to www.virtualsmarthome.xyz (93.90.176.11) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: *   CAfile: /etc/ssl/cert.pem   CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): } [512 bytes data] * TLSv1.2 (IN), TLS handshake, Server hello (2): { [102 bytes data] * TLSv1.2 (IN), TLS handshake, Certificate (11): { [4058 bytes data] * TLSv1.2 (IN), TLS handshake, Server key exchange (12): { [333 bytes data] * TLSv1.2 (IN), TLS handshake, Server finished (14): { [4 bytes data] * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): } [70 bytes data] * TLSv1.2 (OUT), TLS change cipher, Client hello (1): } [1 bytes data] * TLSv1.2 (OUT), TLS handshake, Finished (20): } [16 bytes data] * TLSv1.2 (IN), TLS change cipher, Client hello (1): { [1 bytes data] * TLSv1.2 (IN), TLS handshake, Finished (20): { [16 bytes data] * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use h2 * Server certificate: *  subject: CN=virtualsmarthome.xyz *  start date: Jan 31 10:12:38 2022 GMT *  expire date: May  1 10:12:37 2022 GMT *  issuer: C=US; O=Let's Encrypt; CN=R3 *  SSL certificate verify result: certificate has expired (10), continuing anyway. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x7fb8b6008000) > GET /url_routine_trigger/activate.php?trigger=d1f2c2a5-0bc3-41f3-ac9c-cd3e6b8ca66c HTTP/2
 > Host: www.virtualsmarthome.xyz
 > User-Agent: curl/7.54.0
 > Accept: */*
 >
 * Connection state changed (MAX_CONCURRENT_STREAMS updated)! < HTTP/2 400
 < server: nginx
 < date: Sat, 26 Feb 2022 14:26:44 GMT
 < content-type: text/html; charset=UTF-8
 <
 { [18 bytes data] * Connection #0 to host www.virtualsmarthome.xyz left intact .
   GhostXML Warning                [My Message] - Return code: 127 - Unknown code message.]
   GhostXML Debug                  [My Message] Parse Error: No JSON object could be decoded
   GhostXML Debug                  [My Message] jsonRawData {u'deviceIsOnline': 0, u'parse_error': True, u'deviceLastUpdated': u'02/25/2022 at 20:06', u'deviceTimestamp': 1645841196.057372}
   GhostXML Warning                There was a parse error. Will continue to poll.
   GhostXML Debug                  self.managedDevices: {636300587: <__main__.PluginDevice object at 0x110b43dd0>}

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 8:46 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

Sorry, I shouldn't have said API token, I should have said token authentication. Token authentication is where the client requests a session token from the server (often requiring a password), the server responds with a token, and the token must accompany all other session communication. This isn't the same as a `&token=XXXXXXXX` as a part of the URL itself.

While there's always the potential for a bug, I don't think the plugin is cutting off the URL; what you may be seeing is an affectation of debug logging. I just tested several API token sites and they're working as expected (for example):

Code: Select all
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&apikey=XXXXXXXXXXXXXXX
Attachments
Screen Shot 2022-02-26 at 8.44.48 AM.png
Screen Shot 2022-02-26 at 8.44.48 AM.png (178.36 KiB) Viewed 2485 times

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 26, 2022 9:02 am
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Re: Hopefully plugin related?

Success-ish

I changed authentication method to "None" and it failed. (return code 60 vs previous return code 127)
Code: Select all
   GhostXML Debug                  [My Message] curl error *   Trying 93.90.176.11... * TCP_NODELAY set * Connected to www.virtualsmarthome.xyz (93.90.176.11) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: *   CAfile: /etc/ssl/cert.pem   CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): } [512 bytes data] * TLSv1.2 (IN), TLS handshake, Server hello (2): { [102 bytes data] * TLSv1.2 (IN), TLS handshake, Certificate (11): { [4058 bytes data] * TLSv1.2 (OUT), TLS alert, Server hello (2): } [2 bytes data] * SSL certificate problem: certificate has expired * stopped the pause stream! * Closing connection 0 .
   GhostXML Warning                [My Message] - Return code: 60 - Peer certificate cannot be authenticated with known CA certificates.]
   GhostXML Debug                  [My Message] Parse Error: No JSON object could be decoded
   GhostXML Debug                  [My Message] jsonRawData
   GhostXML Warning                There was a parse error. Will continue to poll.
   GhostXML Debug                  self.managedDevices: {636300587: <__main__.PluginDevice object at 0x110b2ecd0>}

Removed the "s" in the http and it worked.
Code: Select all
Action Group                    URL Routine Trigger - Access Control - Ghost
   GhostXML Debug                  self.managedDevices: {636300587: <__main__.PluginDevice object at 0x110a95cd0>}
   Alexa                           request the value of variable 'my_message'

Leave as is (authentication method none, http, or is there an "https" way I should try?

Either way, I'm pretty excited that I can start making alexa say stuff with indigo.

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 9:18 am
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

That's good news. I'm a bit concerned that it isn't working with https:// -- it should. There's loads of users using secure HTTP successfully with the plugin (me included).

I wonder if it's something to do with an expired (or otherwise messed up) security certificate or something.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 26, 2022 2:16 pm
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Re: Hopefully plugin related?

DaveL17 wrote:
I wonder if it's something to do with an expired (or otherwise messed up) security certificate or something.

I have no idea. From my limited knowledge, I've seen that I will have SSL issues with python 2.7. I tried connecting to the site with a python script following a few different formats I've used successfully with other URL based scripts, but it kept throwing an SSL error in the log or it wouldn't do anything.

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 3:03 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

That's a signal right there. With the type of common URL call we're talking about, it should work with an exceptionally simple Python script.

Code: Select all
import requests

url = 'https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&apikey=XXXXXXXXXXXXX'
r = requests.get(url, timeout=10)
print(r.status_code)
print(r.text)


Code: Select all
================================================================================
Feb 26, 2022 at 3:00:54 PM
untitled text 64
--------------------------------------------------------------------------------
200
{
    "Meta Data": {
        "1. Information": "Daily Prices (open, high, low, close) and Volumes",
        "2. Symbol": "AAPL",
        "3. Last Refreshed": "2022-02-25",
        "4. Output Size": "Compact",
        "5. Time Zone": "US/Eastern"
    },
    "Time Series (Daily)": {
        "2022-02-25": {
            "1. open": "163.8400",
            "2. high": "165.1200",
            "3. low": "160.8738",
            "4. close": "164.8500",
            "5. volume": "91974222"
        },
        "2022-02-24": {
            "1. open": "152.5800",
            "2. high": "162.8500",
            "3. low": "152.0000",
            "4. close": "162.7400",
            "5. volume": "141147540"
        },
[snip]

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 26, 2022 3:08 pm
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Re: Hopefully plugin related?

Yep... but when I try that....

Code: Select all
  Script Error                    embedded script: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)
   Script Error                    Exception Traceback (most recent call shown last):

     embedded script, line 28, at top level
     File "/Library/Application Support/Perceptive Automation/Indigo 2021.2/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/api.py", line 71, in get
       return request('get', url, params=params, **kwargs)
     File "/Library/Application Support/Perceptive Automation/Indigo 2021.2/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/api.py", line 57, in request
       return session.request(method=method, url=url, **kwargs)
     File "/Library/Application Support/Perceptive Automation/Indigo 2021.2/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 477, in request
       resp = self.send(prep, **send_kwargs)
     File "/Library/Application Support/Perceptive Automation/Indigo 2021.2/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/sessions.py", line 587, in send
       r = adapter.send(request, **kwargs)
     File "/Library/Application Support/Perceptive Automation/Indigo 2021.2/IndigoPluginHost.app/Contents/Resources/PlugIns/requests/adapters.py", line 491, in send
       raise SSLError(e, request=request)
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 3:21 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

Yep.

You'll need to update the certificates on your machine (I'm afraid I can't help you there). I think it's also possible to create your own certificate, but I don't recall ever having done that myself.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Feb 26, 2022 5:13 pm
whmoorejr offline
User avatar
Posts: 762
Joined: Jan 15, 2013
Location: Houston, TX

Re: Hopefully plugin related?

About 4 years ago you had a similar issue. (see https://forums.indigodomo.com/viewtopic.php?f=107&t=20794#p163294) Resolved by upgrading PIP which worked for you. It didn't work for me. The results I shared above is after doing what pip upgrades it allows under python 2.7.5

The pip update code from the above thread results in:

Which I did, but didn't help. Oh well, I have the ghost device working and doing what I need it to do. I'm sure https is more secure, but I'm not too worried about someone hacking a fake doorbell. I'm thinking that the worst that they can do is get into my archive of fake doorbells and cause malicious announcements in my house... I'll update my post if I start getting Chinese propaganda announcements on my echo.

Bill
My Plugin: My People

Posted on
Sat Feb 26, 2022 6:33 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Hopefully plugin related?

Yeah, the transition to TLS 1+ broke a lot of stuff. :)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest