-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Login not working #4
Comments
Same problem here, and same error with bad api_key, really strange |
It looks like SpaNet have migrated to a new API. There's swagger documentation here https://app.spanet.net.au/swagger/index.html So far I've only tested the auth endpoint, but was able to get a valid token via: import json
import requests
username = "[email protected]"
password = "my-password"
# I don't know what the validation rules are for the device id,
# I just used a 16-char hex string for a mock android device id and that worked
device_id = "my-device-id"
url = "https://app.spanet.net.au/api/Login/Authenticate"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer ",
}
data = {
"Email": username,
"Password": password,
"UserDeviceId": device_id,
"Language": "en_AU",
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json()) |
Have just investigated and found this too after seeing their new redesigned mobile app. Haven't done any work for a while on this and revisiting it soon, so I will work to recreate this documentation after rewriting my HomeBridge module homebridge-spanet for the new API. Looks like it's going to be a lot nicer to develop from my initial findings that it is using API calls instead of socket for interacting with the spa now? Also @dpretty the swagger documentation has been made private now (presumably seemed to be accidentally public), you didn't happen to download it did you? |
Hello, Thanks to the information from @dpretty, I was able to successfully establish a connection and get the following data back on my POST: first_name: <my first name, which i gave when registering for spanet> But what do I do with the token now. The two links from @dpretty above no longer work. I can't find any documentation on how to query data from the hot tub. |
@Eldarion85 Your authentication there looks correct, after that you then use the access token in your requests by setting the
If you email my gmail on my account I can reply to you with the full Swagger documentation listing all the endpoints and expected payloads |
Sorry I missed this notification. I do have a local copy as I guessed it might not remain public...
... but it sounds like you have it now anyway? |
@dpretty Yes I did get sent it, thanks for your discoveries |
@BlaT2512 Now I just need to know the other API addresses, then everything works fine. I will email you directly for documentation. Thank you both, great work :). |
@dpretty |
I have since been helped with the documents and have been successful at creating general queries to the api. Need to work with the app some more to find permitted values for various Put and Post commands. Will PR to @dpretty repo. In that process I have been wondering: Has anyone worked out: Addendum: In answer to myself: "How to work with the refresh_token?" Adendum 2: |
Updates: |
Hi all, |
Hello, thanks for your research @GuiHue. I currently have everything disabled because I found out with Wireshark that the spa link has a bug when setting it up. The DHCP exchange with the DHCP server is faulty and does not work with more expensive DHCP servers that value security. Only after clearing that up will I get back to the API and share my information here. |
Hi everyone, |
I am having the same issue |
Interesting that the 'Information' request still works incl. the previous ID, but the 'Dashboard' doesn't, so you can't retrieve and set the main temperature setting. Has anyone got the ability to listen in to the communication between app and their servers? The app hasn't changed. |
Does anyone have any updates? I did not have much time in the past weeks but managed to have a look at things today. As written by someone else elsewhere, the API appears to have undergone changes again. Most crucially, the call to https://app.spanet.net.au/api/Devices still returns [200] indicating success but does not contain a payload. This means that we cannot get the deviceID that is mandatory for all other queries. (I appear to have missed the previous comments: The above concurs with @hwurst205 statements.) |
Hello, Something has changed and now it no longer works in my spa. |
@GuiHue @Eldarion85 Happy to send a copy of the swagger docs and the API call code I am using if you are still having trouble, just checked and I am able to successfully log in and get all of my spa data |
Hey Blake, |
Thank you for your email @BlaT2512 . I'll write the result here because it might help others too. The tip with the user agent was crucial. I just added the line "User-Agent": "SpaNET/2 CFNetwork/1465.1 Darwin/23.0.0" to my GET. I had the WIFI module V2 until two weeks ago. But there was an error in the DHCP handling, which most users with standard routers don't notice. So Spanet sent me a WIFI module V3. I swapped it and the DHCP handling error was resolved. But I still have one question. Where do I get the UserDeviceID? It doesn't matter what I write in there, it just works. It only doesn't work if you leave out the field in the header. Can I query the ID somehow or do you just make something up? In the image below I'm sending "???" and still get my token. Many thanks for your effort! |
@Eldarion85 Glad that you were able to get it working! |
Thank you @BlaT2512 and @Eldarion85 for your input. While I have not been able to test myself, I assume that this is the crucial part. Hope to get to this on the weekend. |
@Eldarion85, @BlaT2512. Same here, I was able to get a response from the 'Devices' endpoint after adding this User-Agent, previously it was blank. I have been following the issue recently having only recently had a spa installed but that is the only endpoint I know of for now. Sent an email as well for the documentation. |
FYI upon further investigation, UserDeviceID is encrypted into the JWT access / refresh tokens so likely useful for the server to invalidate tokens e.g. log out all devices. Access tokens provided when logging in at the login endpoint are also valid for 7 days from issue. Refresh tokens don't seem to have expiry date as the API is designed for mobile app. |
Hey @BlaT2512 , I am currently on the old version of SpaNet (SpaLink) and looking at migrating to the new app (SmartLink) as the current one is being discontinued from 30/11/23. Could you please send me the swagger doco and any sample code to integrate to Home Assistant? Cheers, |
Hey @BlaT2512 , I have been following previous conversations and now I'm up to where I can get the device information and dashboard using these endpoints: response something like: but I still not sure how to do an update (ie. set new temperature), have you found out how to do this? Thanks so much. |
Hi all, Just stumbled across this as Im trying to integrate my spa with Homeseer. Spanet SV Firmware is V6 21 12 13 App on mobile works fine. Was wondering if a) any hints on what I might be getting wrong Thanks |
Scratch that .. mental lapse, just realised the original account was setup as login with google so of course the passwords dont match. I now have an access token. Can you share the api with me so I can move to the next phase please :) ? |
Hi all, thanks for all the great work, would also love some code snippets/api doco so I can make this work with NodeRED/Hassio! |
This is a bit of python (its not clean, but it should show you how to grab your token, and your spaID and run a few queries Hope it helps import json username = "aaaaaaaa" just a random number to align with me this is mac address of skywalkerdevice_id = "bcccccccc0000" authenticate and grab a token for follow up queriesurl = "https://app.spanet.net.au/api/Login/Authenticate" headers = { if response.status_code == 200:
these are just a bunch of queries that are possible from the api .. stored here for my reference#response = requests.get("https://app.spanet.net.au/api/Devices", headers=headers,data=json.dumps(data))
else: |
I created some code for my own use to interact with the api and set
temperature amongst other things. For temperature it is set in the
Dashboard endpoint. This is not a comprehensive list of functions as I have
only added the ones I need for now but it handles token refreshes too. You
would need to pick out the bits that are suitable from this:
https://gist.github.com/ellyse18/1c12961a2d06ff4f6a192a6791abe0f1
Ellyse
…On Thu, Jun 6, 2024 at 6:58 PM Lloyd Weehuizen ***@***.***> wrote:
Hey all, thanks to the URLs above I was able to update my existing
HomeAssistant plugin to display the Spa information.
Screen.Shot.2024-06-06.at.8.55.11.PM.png (view on web)
<https://github.com/BlaT2512/spanet-api/assets/297244/850d4382-90da-4c57-9b6c-e85f6a9027c2>
If anybody has anymore info on how to set the temperature and refresh the
access token that would be highly appreciated!
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARCMAGPRRCSZJKCKMD3RSCTZGAQCPAVCNFSM6AAAAAAWN6NTC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJRG43DKOBTGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
If you want to change the powersave mode, you do that through the settings tree (XXXX are SpaID) using mode, startTime and endTime
response = requests.put("https://app.spanet.net.au/api/Settings/PowerSave/XXXX", headers=headers, json=mydata) |
How do I set the lights on or off? if I call this: I get something like this: I think I just need to make "lightOn":True. but it wouldn't work. thx |
I hadnt played with this, but I had a look at the code https://github.com/BlaT2512/homebridge-spanet/blob/master/src/platformAccessory.ts#L170 It appears more strange methods are used. XXXX are the spaID, YYYY are the accessory (or component ID). In your case above, the lightId would be used for the YYYY. To turn the lights on and off you need to do something like :
requests.put("https://app.spanet.net.au/api/Lights/SetLightStatus/YYYY", headers=headers, json=mydata) To change colour you do something different again
requests.put("https://app.spanet.net.au/api/Lights/SetLightColour/YYYY", headers=headers, json=mydata) One thing I did find when I was experimenting just now, is that I need to be a little patient. ie sometimes the changes didnt happen instantly. |
Something else I just worked out .. if the lights are off, and you set a lights mode, it will turn them on at the same time as setting the mode (just thought this might be interesting to know) :) |
I can control the lights now. Thanks @gdarby70 |
Would you mind sharing how you build this? I have just installed the v2 wireless unit which is reporting back to the app as expected. Started to following this thread but cant even get a response from the urls mentioned here that includes the https://app.spanet.net.au/api/ from a basic node red flow or even a browser? If possible can some one guide me on the basic steps to get me going please? |
@droidblastnz I will be updating my existing plugin (https://github.com/lloydw/hass-spanet/) with this new api in the next couple of days, I just need to make sure it works on the lastest homeassistant. I'm still only 2023.5 😂 |
Would you mind sharing your flow please? I am trying to integrate to Home Assistant via what ever means works and I do have a lot of node red flows but http request for some time now is broken and reports "RequestError: connect ECONNREFUSED 127.0.0.1:443 : https://app.spanet.net.au/api/Login/Authenticate" |
It looks like a problem with your configuration. It shouldn't be tring to connect to 127.0.0.1? |
You cant paste the URLs into your browser. You need to build the correct headers, and payloads etc. I dont use HA or Node Red (I use Homeseer), so my code will be quite different to yours, but the flow is generally the same. |
Good Morning, |
Many thanks any chance you can export the flow minus your details please? Struggling to get started :( |
Here is the flow for importing into Node-RED. Apart from the user name, password and user device ID in the "POST erzeugen" node, you don't have to enter anything. Everything else is standard. |
For your information: As you can see, my flow has some waiting times built in. I always wait 5 seconds before the next request and after I have collected all 6 responses, I send them out as a package. That's why it takes about 30 seconds until you see the data in the debug after the trigger. |
Many thanks as this will help me get to the end result. I will post back once I have it working as I am running Home Assistant on a Rasberry Pi and have a issue with the http node - "RequestError: connect ECONNREFUSED 127.0.0.1:443" which I need to resolve or replace with a exec node etc. |
Because I don't use a Home Assistant, I can't help you with that. I use ioBroker with Node-RED. Until two years ago, I also used it on a Raspberry Pi, now I use Proxmox. |
Thanks missed this comment. Add the spanet to custom components and rebooted home assistant and then added to the dashboard. Running Home Assistant 2024.6.1 Still keen to have node red some automation as we have PV Cells on the roof and keen to adjust the heating etc of the Spa depending on the day and sunlight available. |
Since late last week I have noticed a few changes to the API. Now have a rate limit of 60 calls per hour. Also the endpoint to update filtration settings has stopped working. |
Has anybody worked out which |
Not sure but is this is what you are looking for or already reference it: https://github.com/wayne-love/spanet-api/blob/main/spanet.md#42-pumps |
Thanks for the link, yeah I think this is the old protocol? As the new protocol 1 is ON, and 2 if OFF, 0 does nothing as far as I can tell. |
UPDATED: I found the cause of this: It looks like the Request Headers need to be set in multiple commands, perhaps because the access token is rather long. For the authentication, they headers could be in one command without error, but not for devices. Hope this helps others using VBA. First of all, many thanks for all the great contributions, what a treasure trove of info. I am in the early stage of writing VBA code to connect to the SpaNet API. Thanks to the helpful posts above, I have already added the header "User-Agent", "SpaNET/2 CFNetwork/1465.1 Darwin/23.0.0", so that shouldn't be the problem. Should my VBA login authentication (on Windows) not list the same spas devices that are listed in my SpaNet app on Android? (using the same account of course.) Many thanks for your insights and help. |
Hello everyone, I wrote a function in Node-RED that sorts all messages neatly structured into two objects. One for control and the other for the status. In addition, the setup is extremely easy, as you only have to install the MQTT server (2 minutes) and enter the access data in the SpaNet app. Have you already tested it over a longer period of time? Are there any disadvantages that you know of or functions that don't work? So far, I'm impressed with how well it works. Best wishes |
Hi,
great work here.
However, the login process does not appear to be working for my spanet account ("Wrong Login!" result to POST).
Can someone confirm that the API key and password encryption algorithm has not changed?
Thanks
Stefan
The text was updated successfully, but these errors were encountered: