ha-smartmetertexas icon indicating copy to clipboard operation
ha-smartmetertexas copied to clipboard

No readings Returned

Open daviswieck opened this issue 2 years ago • 24 comments

Making new issue as well as commenting on old similar issue..

It appears this could be happening again... Last data it grabbed was on Nov. 11 at 11:50pm... Nothing since then.

Getting an "ECONNRESET" error on the "Log In" node and "Request Read" Node.

Running HA 2022.11.2 through virtual machine.

daviswieck avatar Nov 15 '22 14:11 daviswieck

Looks like they may be blocking access.

First https://smartmetertexas.com isn't working for me; I had to update it to https://www.smartmetertexas.com

Second, when testing the authenticate post in Postman I get an access denied error:

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>
 
You don't have permission to access "http&#58;&#47;&#47;www&#46;smartmetertexas&#46;com&#47;api&#47;user&#47;authenticate" on this server.<P>
Reference&#32;&#35;18&#46;85ed19b8&#46;1668529535&#46;a90ff58
</BODY>
</HTML>

EDIT: With some cursory testing -- it looks like it's requiring cookies present after loading the home page (e.g. via browser) to be passed back with the authentication request. Trying without the Cookie header in curl gives me the above error, but copying the cookie from the request in Firefox and running the curl command will work.

shbatm avatar Nov 15 '22 16:11 shbatm

@shbatm how did you get it work with adding the cookie? Have you tried Postman or Iosomina? If so do you have a screen shot of your code or curl command

andrewchumchal avatar Nov 15 '22 23:11 andrewchumchal

I was only able to mess with it briefly today--I captured the network requests with Firefox Dev-Tools (right-click>Inspect, Network Tab) which lets you copy the requests as curl. Using the curl commands I tried a few things on the command line and compared to the requests from Postman and NR.

Summarizing what I found: browsing to http://www.smartmetertexas.com redirects you to /dashboard, sets 4 cookies, and sends you to the login screen. When you log in, the cookies are sent back in the header. I took this response and "replayed" it as-is in curl and got the expected JSON response back. When I dropped the cookie header, I would get the above Access Denied. Got the same Access Denied from Postman and from NR.

shbatm avatar Nov 15 '22 23:11 shbatm

Thank you for that. It appears if i copy the curl and run it runs fine but if I import into postman it fails.

andrewchumchal avatar Nov 15 '22 23:11 andrewchumchal

home-assistant/core/issues/57582 has a lot of information that retains this issue. It appears to have been a issue with SMT. Where www. point to their CDN but doman.com pointed to there server and they have since turn off going straight to the domain.

andrewchumchal avatar Nov 16 '22 01:11 andrewchumchal

So grabbing the cookies and sending them back in the header, would that make it possible to add those into the node-red flow? I've been watching this and the core integration issue to see what people are doing.

twmcelroy avatar Nov 17 '22 23:11 twmcelroy

I will work on a way to handle the cookies, but it may take a bit to get implemented and tested.

stmrocket avatar Nov 18 '22 03:11 stmrocket

I'm more of a backend developer but I can fumble my way through with some instructions. Happy to test (working around family coming into town this week).

twmcelroy avatar Nov 18 '22 04:11 twmcelroy

I've done some digging and testing on this myself, and I believe they have bot detection/protection from Akamai running, which is preventing this from working. I was playing/testing a lot with headers and cookies (was even storing the cookies and trying to send them with my POST for authentication without any luck). I was testing with Postman as well, and even it was failing. More details here:

https://www.zenrows.com/blog/bypass-akamai https://stackoverflow.com/questions/69562016/akamai-sensor-data-generator-for-a-valid-abck-cookie-on-post-request-python https://github.com/zedd3v/abck

mflagler avatar Nov 18 '22 21:11 mflagler

The HA integration has started working again. Not sure about the Node-Red integration

twmcelroy avatar Nov 20 '22 22:11 twmcelroy

The HA integration never worked for me. Just tried it and it works now. Interesting.

daviswieck avatar Nov 20 '22 22:11 daviswieck

NodeRED Flow is working again for me (removed www.)

shbatm avatar Nov 22 '22 00:11 shbatm

The node-red flow appears to be working for now. Let's see how long it takes from them to break it now.

andrewchumchal avatar Nov 22 '22 01:11 andrewchumchal

This is the response I'm getting back:

Error

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

cpettis avatar Jul 11 '23 15:07 cpettis

Looks like it happened again.... smart meter Texas upgraded their service to SMT V2 and it broke... looks like it affect the integration version as well..

https://github.com/home-assistant/core/issues/111118

daviswieck avatar Mar 01 '24 03:03 daviswieck

Any update on this? I'm still not able to get this integration working since SMT updated.

TGrounds avatar Mar 13 '24 19:03 TGrounds

I think I've narrowed the problem down to a few things:

  1. The API authentication URL has changed to /commonapi/user/authenticate
  2. The Headers must contain a user-agent.
  3. The request must be an HTTP/2 request -- which I cannot find out how to support from Node-RED.

I was able to get a rough python script working to prove that it's still viable:

https://gist.github.com/shbatm/d10a703cc3e3817e9bf53fec9eae52a6

I just haven't been able to get the Node-RED Flow back working since I can't find much on the request node's support for HTTP/2.

shbatm avatar Apr 08 '24 09:04 shbatm

I did some playing in Node-RED and got it to work (at least for one read, so we'll see if it continues working).

I updated all the "Apply HTTP Config" entities with all the updated headers from your example, then replaced all the https-node entities with regular http request entities and configured them the same with the exception of the first one that authenticates where I used your updated URL.

See if it works for anyone else.

Edit: attached my flow here smart-meter-texas-flow.json

mflagler avatar Apr 09 '24 01:04 mflagler

Your updated flow is working for me...thanks

jeffgraham-hub avatar Apr 10 '24 16:04 jeffgraham-hub

~I forked the repo and made it using various solutions offered by several people, like @mflagler (Thanks for sharing your flow!). Since I think this repo has become inactive, I decided to create a fork that I will maintain as best as I can, and I included two flows, one of which will parse data to mqtt, and the other to home assistant via custom node red integration. Give it a try and let me know how it works!~

I have been corrected, and will be submitting a PR.

Indianb0y016 avatar Apr 12 '24 18:04 Indianb0y016

This repo isn't inactive per-se. I just don't directly use this integration as I initially created it for a friend (I have local power monitoring). I'm happy to merge the changes if you wish to submit a PR.

On Fri, Apr 12, 2024 at 1:35 PM Indianb0y016 @.***> wrote:

I forked the repo and made it using various solutions offered by several people, like @mflagler https://github.com/mflagler (Thanks for sharing your flow!). Since I think this repo has become inactive, I decided to create a fork that I will maintain as best as I can, and I included two flows, one of which will parse data to mqtt, and the other to home assistant via custom node red integration. Give it a try and let me know how it works!

— Reply to this email directly, view it on GitHub https://github.com/stmrocket/ha-smartmetertexas/issues/14#issuecomment-2052269968, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETJ6CKGJORWZ7C5STBR4HDY5ASOVAVCNFSM6AAAAAASBA6QOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGI3DSOJWHA . You are receiving this because you commented.Message ID: @.***>

stmrocket avatar Apr 12 '24 18:04 stmrocket

This repo isn't inactive per-se. I just don't directly use this integration as I initially created it for a friend (I have local power monitoring). I'm happy to merge the changes if you wish to submit a PR. On Fri, Apr 12, 2024 at 1:35 PM Indianb0y016 @.> wrote: I forked the repo and made it using various solutions offered by several people, like @mflagler https://github.com/mflagler (Thanks for sharing your flow!). Since I think this repo has become inactive, I decided to create a fork that I will maintain as best as I can, and I included two flows, one of which will parse data to mqtt, and the other to home assistant via custom node red integration. Give it a try and let me know how it works! — Reply to this email directly, view it on GitHub <#14 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETJ6CKGJORWZ7C5STBR4HDY5ASOVAVCNFSM6AAAAAASBA6QOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGI3DSOJWHA . You are receiving this because you commented.Message ID: @.>

Ahh my apologies. I figured since the last pull request hadnt been merged, I assumed that it was no longer active. Im still learning github, so I apologize. Allow me to take down my fork references and modify it for merging.

Indianb0y016 avatar Apr 12 '24 18:04 Indianb0y016

This repo isn't inactive per-se. I just don't directly use this integration as I initially created it for a friend (I have local power monitoring). I'm happy to merge the changes if you wish to submit a PR. On Fri, Apr 12, 2024 at 1:35 PM Indianb0y016 @.> wrote: I forked the repo and made it using various solutions offered by several people, like @mflagler https://github.com/mflagler (Thanks for sharing your flow!). Since I think this repo has become inactive, I decided to create a fork that I will maintain as best as I can, and I included two flows, one of which will parse data to mqtt, and the other to home assistant via custom node red integration. Give it a try and let me know how it works! — Reply to this email directly, view it on GitHub <#14 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETJ6CKGJORWZ7C5STBR4HDY5ASOVAVCNFSM6AAAAAASBA6QOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJSGI3DSOJWHA . You are receiving this because you commented.Message ID: _@**.**_>

Ahh my apologies. I figured since the last pull request hadnt been merged, I assumed that it was no longer active. Im still learning github, so I apologize. Allow me to take down my fork references and modify it for merging.

No problem! Funny thing is, I was thinking I needed to get that other PR merged at some point soon just the other day. I see your PR and will try to get it reviewed and merged shortly. Thank you!

stmrocket avatar Apr 13 '24 02:04 stmrocket

Gave @Indianb0y016 flow a try (NodeRed with HA, no MQTT) and got my first reading! I will keep watching to see how it does for the next day.

twmcelroy avatar Apr 22 '24 00:04 twmcelroy

The fixes from @Indianb0y016 have been merged into this repository via PR #15

stmrocket avatar May 03 '24 17:05 stmrocket