Skip to content
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

Open
hwurst205 opened this issue Mar 30, 2023 · 58 comments
Open

API Login not working #4

hwurst205 opened this issue Mar 30, 2023 · 58 comments
Assignees
Labels
question Further information is requested

Comments

@hwurst205
Copy link

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

@hwurst205 hwurst205 added the question Further information is requested label Mar 30, 2023
@mathieusachet
Copy link

Same problem here, and same error with bad api_key, really strange

@dpretty
Copy link

dpretty commented Jun 2, 2023

It looks like SpaNet have migrated to a new API.

https://app.spanet.net.au/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())

@BlaT2512
Copy link
Owner

BlaT2512 commented Jul 8, 2023

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?

@Eldarion85
Copy link

Hello,
I would like to integrate my Vortex Spa into the home automation. I can confirm that it no longer works as in the current documentation.
I use NodeRed and would like to get the current data from the whirlpool from there.

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>
access_token: <272 long token>
refresh_token: <50 long token>
reset_password: false

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.

Vortex

@BlaT2512
Copy link
Owner

BlaT2512 commented Jul 31, 2023

@Eldarion85 Your authentication there looks correct, after that you then use the access token in your requests by setting the authentication header in requests to Bearer <access_token>. For example, you can start by making a request to the Devices endpoint to list the devices on your account. The curl below is an example:

curl -X GET https://app.spanet.net.au/api/Devices -H "Authorization: Bearer <access_token>"

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

@dpretty
Copy link

dpretty commented Jul 31, 2023

@BlaT2512

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?

Sorry I missed this notification. I do have a local copy as I guessed it might not remain public...

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

... but it sounds like you have it now anyway?

@BlaT2512
Copy link
Owner

@dpretty Yes I did get sent it, thanks for your discoveries

@Eldarion85
Copy link

@BlaT2512
Many thanks for the quick response!
I just tried it and with the token I get my device details as a reply. Name and MAC match, so it works perfectly.

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 :).

Devices

@GuiHue
Copy link

GuiHue commented Aug 14, 2023

@dpretty
Would it be possible to receive a copy of the swagger docs? Love to join the effort!

@GuiHue
Copy link

GuiHue commented Aug 16, 2023

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.
Thus far I have done everything in plain Python. I have started to play with node-red as developing an entire integration in homeassistant is beyond my skill level (and exceeds the permissible time budget).

In that process I have been wondering: Has anyone worked out:
a) how long the access token is valid?
b) how many api requests per 24h are ok (specially when querying the dashboard)?

Addendum: In answer to myself: "How to work with the refresh_token?"
apiOAuthTokenPost in Docs is the place to look: Send a request with refresh_token and userDeviceID (generated by you, same as during auth) and you get a new token. Now, all that's needed is to work out how long the access_token is good for. Ill give that a short test using a loop.

Adendum 2:
I queried the dashboard for several hours at an intervall of 300s (5'): no complaints.
Furthermore: Access Token seems to be good for at least 24h.

@GuiHue
Copy link

GuiHue commented Aug 18, 2023

Updates:
I did 120 Minutes of continuous QUerys to the Dashboard at Intervalls of 60s without complaints
I have been using the same access_token since 36h by now.

@GuiHue
Copy link

GuiHue commented Aug 26, 2023

Hi all,
some progress over time: I managed to implement all GET functions via node-red and transfer the results to homeassistant. Thats good - BUT:
The SmartlInk app and the API server have become unresponsive several times throughout the last week. Often for multiple hours. I dont think it is throttling towards my account or IP, but rather a general problem.
Can anyone confirm?

@Eldarion85
Copy link

Hello,

thanks for your research @GuiHue.
Unfortunately, I have only tested a few GET queries with Node-RED so far to see if it basically works. Unfortunately, I can't yet answer how long the access token is valid and at what intervals you can query it.

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.
DHCP Discovery (from client) and DHCP Offer (from server) are OK, but then the client sends a wrong DHCP request to the server, so better DHCP servers do not assign an IP address and reject the connection.
This probably affects all Spa-Link devices on the market and I am in contact with the manufacturer.

Only after clearing that up will I get back to the API and share my information here.

@hwurst205
Copy link
Author

Hi everyone,
it appears like 5 days ago (Sept 7th), the API has somehow changed. The auth process still works but the device query returns an empty array. The previous device ID no longer works. Does anyone else have the same problem?

@dr0ck324
Copy link

I am having the same issue

@hwurst205
Copy link
Author

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.

@GuiHue
Copy link

GuiHue commented Sep 27, 2023

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.
Oddly enough, the request to https://app.spanet.net.au/api/Information/ with my old deviceID (which I had stored) still works fine. A similar request to dashboard return 400.

(I appear to have missed the previous comments: The above concurs with @hwurst205 statements.)

@Eldarion85
Copy link

Hello,
Today I finally got around to testing my connection to the spa again and can confirm @GuiHue.
The status code 200 still appears on the POST "https://app.spanet.net.au/api/Login/Authenticate" and the GET "https://app.spanet.net.au/api/Devices", but it has the array of devices without payload.

Something has changed and now it no longer works in my spa.

@BlaT2512
Copy link
Owner

BlaT2512 commented Nov 2, 2023

@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

@Eldarion85
Copy link

Hey Blake,
I sent you an email like last time. If you would send me the documentary that would be great.
Thank you!

@Eldarion85
Copy link

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 previously received a response with status 200, but the device list was always empty. Now the device is back in the payload and everything works.
Strange that it worked before without the user agent in the header.

User-Agent

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.
However, I doubt whether the module has anything to do with the fact that it previously worked without the user agent. Maybe something was changed in the API. But whatever, the main thing is that it works again.

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.

Request_Response_Authenticate

Many thanks for your effort!

@BlaT2512
Copy link
Owner

BlaT2512 commented Nov 2, 2023

@Eldarion85 Glad that you were able to get it working!
The UserDeviceID is a unique UUID string to identify the SpaLINK app the request comes from, unique to each iPhone/Android. The server likely uses it only for the purpose of checking it against a blacklist or something, so yes you can use a random string. In Swift this is UIDevice.current.identifierForVendor!.uuidString

@GuiHue
Copy link

GuiHue commented Nov 2, 2023

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.

@ellyse18
Copy link

ellyse18 commented Nov 2, 2023

@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.

@BlaT2512
Copy link
Owner

BlaT2512 commented Nov 3, 2023

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.

@kylev12
Copy link

kylev12 commented Nov 17, 2023

Hey @BlaT2512 ,
Great work on the SpaNet API.

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.
Currently using a varied sn2ha config to queries at SpaNet API to have access to both app and HA but has caused errors in the past and my programming knowledge is limited.

Could you please send me the swagger doco and any sample code to integrate to Home Assistant?
Any help would be greatly appreciated!

Cheers,
Kyle

@rjulianc
Copy link

rjulianc commented Dec 6, 2023

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:
https://app.spanet.net.au/api/Information/
and
https://app.spanet.net.au/api/Dashboard/

response something like:
{"deviceName":"xxxx","currentTemperature":294,"setTemperature":320,"dateTime":"07/12/2023 10:54:00 PM","lastUpdatedDateTime":"07/12/2023 11:56:02 AM","statusList":["Sleeping"],"warningStatusList":[],"hasError":false,"sanitiseOn":false,"updateAvailableVersion":"SV V6 231107"}

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.

@gdarby70
Copy link

Hi all,

Just stumbled across this as Im trying to integrate my spa with Homeseer.
Have tried the python snipet above, but I keep getting 401 responses.
Have tried clear password, encrypted password etc but no difference.

Spanet SV Firmware is V6 21 12 13
WiFi v1.07
App version 1.10(27)

App on mobile works fine.

Was wondering if

a) any hints on what I might be getting wrong
b) if someone can send me the api docs for when I am successful

Thanks

@gdarby70
Copy link

Hi all,

Just stumbled across this as Im trying to integrate my spa with Homeseer. Have tried the python snipet above, but I keep getting 401 responses. Have tried clear password, encrypted password etc but no difference.

Spanet SV Firmware is V6 21 12 13 WiFi v1.07 App version 1.10(27)

App on mobile works fine.

Was wondering if

a) any hints on what I might be getting wrong b) if someone can send me the api docs for when I am successful

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 :) ?

@vlat0101
Copy link

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!

@gdarby70
Copy link

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
Obviously put your own username and password in. The xxxx in the commented out lines are actually your spaID, I had them hardcoded when I was testing

Hope it helps

import json
import requests
import sys

username = "aaaaaaaa"
password = "bbbbbbb" # (note this is in keeper)

just a random number to align with me this is mac address of skywalker

device_id = "bcccccccc0000"

authenticate and grab a token for follow up queries

url = "https://app.spanet.net.au/api/Login/Authenticate"

headers = {
"User-Agent": "SpaNET/2 CFNetwork/1465.1 Darwin/23.0.0",
"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))

if response.status_code == 200:
#print(response.json())
#print(response.json().get('access_token'))

headers["Authorization"] = "Bearer " + response.json().get('access_token')

# send a query to grab the spaId which is needed for certain requests later

response = requests.get("https://app.spanet.net.au/api/Devices", headers=headers,data=json.dumps(data))
spaId = response.json().get('devices')[0]['id']

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))
#response = requests.get("https://app.spanet.net.au/api/Dashboard/xxxx", headers=headers,data=json.dumps(data))
#response = requests.get("https://app.spanet.net.au/api/Information/xxxx", headers=headers,data=json.dumps(data))
#response = requests.get("https://app.spanet.net.au/api/PumpsAndBlower/Get/xxxx", headers=headers,data=json.dumps(data))
#response = requests.get("https://app.spanet.net.au/api/Lights/GetLightDetails/xxxx", headers=headers,data=json.dumps(data))
#response = requests.get("https://app.spanet.net.au/api/SleepTimers/xxxx", headers=headers,data=json.dumps(data))

if len(sys.argv)>1:
    response = requests.get("https://app.spanet.net.au/api/" + sys.argv[1]+"/"+str(spaId), headers=headers,data=json.dumps(data))
else:
   print ("got spa id "+str(spaId))
   response = requests.get("https://app.spanet.net.au/api/Devices", headers=headers,data=json.dumps(data))

# this block was me attempting a "set" to change the operation mode (which also worked)

mydata = {
  "mode": 4,   # 1=NORM, 2=ECON, 3=AWAY, 4=WEEK  
 }

#response = requests.put("https://app.spanet.net.au/api/PumpsAndBlower/SetBlower/xxxx", headers=headers, json=mydata)
#response = requests.put("https://app.spanet.net.au/api/Settings/OperationMode/xxxx", headers=headers, json=mydata)

if response.status_code == 200:
     print(response.json())
else:
    print("Failed request " + str(response.status_code))

else:
print("Failed authentication " + str(response.status_code))

@lloydw
Copy link

lloydw commented Jun 6, 2024

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

If anybody has anymore info on how to set the temperature and refresh the access token that would be highly appreciated!

@ellyse18
Copy link

ellyse18 commented Jun 6, 2024 via email

@rjulianc
Copy link

rjulianc commented Jun 6, 2024

Thanks @ellyse18 @gdarby70

@gdarby70
Copy link

gdarby70 commented Jun 6, 2024

If you want to change the powersave mode, you do that through the settings tree (XXXX are SpaID) using mode, startTime and endTime

mydata = {
  "mode": 1,   # 1=OFF, 2=LOW, 3=HIGH  
   #"startTime": "15:00",
   #"endTime": "22:30",
 }

response = requests.put("https://app.spanet.net.au/api/Settings/PowerSave/XXXX", headers=headers, json=mydata)

@rjulianc
Copy link

rjulianc commented Jun 7, 2024

How do I set the lights on or off?

if I call this:
https://app.spanet.net.au/api/Lights/GetLightDetails/xxxx

I get something like this:
{"lightId":xxxx,"lightMode":"fade","lightColour":"white","lightBrightness":5,"lightSpeed":5,"lightOn":false}

I think I just need to make "lightOn":True. but it wouldn't work.

thx

@gdarby70
Copy link

gdarby70 commented Jun 7, 2024

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 :

mydata = {
  "deviceId": XXXX,
  "on": True,
 }

requests.put("https://app.spanet.net.au/api/Lights/SetLightStatus/YYYY", headers=headers, json=mydata)

To change colour you do something different again

mydata = {
  "deviceId": XXXX,
  "colour": "green",
 }

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.

@gdarby70
Copy link

gdarby70 commented Jun 7, 2024

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) :)

@rjulianc
Copy link

rjulianc commented Jun 7, 2024

I can control the lights now. Thanks @gdarby70

@droidblastnz
Copy link

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

If anybody has anymore info on how to set the temperature and refresh the access token that would be highly appreciated!

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?

@lloydw
Copy link

lloydw commented Jun 9, 2024

@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 😂

@droidblastnz
Copy link

Hello, I would like to integrate my Vortex Spa into the home automation. I can confirm that it no longer works as in the current documentation. I use NodeRed and would like to get the current data from the whirlpool from there.

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> access_token: <272 long token> refresh_token: <50 long token> reset_password: false

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.

Vortex

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"

@lloydw
Copy link

lloydw commented Jun 9, 2024

It looks like a problem with your configuration. It shouldn't be tring to connect to 127.0.0.1?

@gdarby70
Copy link

gdarby70 commented Jun 9, 2024

Hello, I would like to integrate my Vortex Spa into the home automation. I can confirm that it no longer works as in the current documentation. I use NodeRed and would like to get the current data from the whirlpool from there.
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> access_token: <272 long token> refresh_token: <50 long token> reset_password: false
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.
Vortex

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"

You cant paste the URLs into your browser. You need to build the correct headers, and payloads etc.
It requires a script in your favourite language, to authenticate (username/password used in the spanet app), to receive a "token". You then use that token as part of subsequent requests to get status or set values.

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.
The scrap of python code I posted, will show you the general flow, you just need to convert to your language/platform needs.

@Eldarion85
Copy link

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"

Good Morning,
I used Node-RED to retrieve all relevant data. I trigger this once every 5 minutes. First, I check whether I already have an Access_Token and User_Agent. If not, I retrieve it. If so, I retrieve the devices using "https://app.spanet.net.au/api/Devices". If this was successful, I retrieve all other data. If not, my Access_Token is no longer valid and I automatically retrieve it again. This has been running unchanged for many months without a single failure or error.

image

@Eldarion85
Copy link

I just noticed that the name of the node in the top row is wrong. Instead of "POST Limit" it should say "POST Authentication".
Copy/paste error because I copied it from my flow for the photovoltaic system :D.

image

@droidblastnz
Copy link

I just noticed that the name of the node in the top row is wrong. Instead of "POST Limit" it should say "POST Authentication". Copy/paste error because I copied it from my flow for the photovoltaic system :D.

image

Many thanks any chance you can export the flow minus your details please? Struggling to get started :(

@Eldarion85
Copy link

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.

image

Whirlpool.json

@Eldarion85
Copy link

Eldarion85 commented Jun 9, 2024

For your information:
You can make up the user device ID yourself. I simply use a 16-character Code (for example: AGL7GDFP53AS72DP). The only important thing is that no one else uses the same one.

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.

@droidblastnz
Copy link

For your information: You can make up the user device ID yourself. I simply use a 16-character Code (for example: AGL7GDFP53AS72DP). The only important thing is that no one else uses the same one.

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.

@Eldarion85
Copy link

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.
But if your Node-RED is running, you import my flow and only enter the information (user, password and user device ID), you should get the data from your spa in any case, regardless of your Home Assistant.
Let me know if it works :).

@droidblastnz
Copy link

droidblastnz commented Jun 9, 2024

@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 latest homeassistant. I'm still only 2023.5 😂

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
image

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.

@ellyse18
Copy link

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.

@lloydw
Copy link

lloydw commented Jun 24, 2024

Has anybody worked out which modeId are supported on the pumps? Simple on/off pumps work great with 1 on and 2 off (why is 2 off?), but I've now encountered pumps that support auto/low/high and not sure how to set them into auto/low/high modes.

@ellyse18
Copy link

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
Pump 1 has auto and others don't. Auto is modeId: 4? Not sure about variable speeds, I can see the blower can vary from 1 to 5 but can't see the same for the pumps.

@lloydw
Copy link

lloydw commented Jun 25, 2024

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 Pump 1 has auto and others don't. Auto is modeId: 4? Not sure about variable speeds, I can see the blower can vary from 1 to 5 but can't see the same for the 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.

@jpt60
Copy link

jpt60 commented Jul 1, 2024

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.
I manage to successfully authenticate, and send the GET command for the list of devices. However, what it returns an empty list, like this:
{"devices":[]}

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.

@Eldarion85
Copy link

Hello everyone,
it annoys me that the app is constantly causing problems and that I have to log in again when I retrieve the data via the API. In addition, something often changes in the API, so you always have to make improvements yourself. That's why I played around with MQTT today.

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.
When you log in to the server for the first time, all the configurations that the spa has are automatically sent.
After that, the spa always sends a message immediately when something changes, without having to trigger it manually.
There is also a control signal for "Discovery", which updates all status messages again. I currently do this every 5 minutes in my test system.
I have tested all the functions of pumps, blowers, heating, lighting... and everything can be controlled perfectly. The app immediately shows the changes that I send with Node-RED via MQTT and no longer constantly logs out.

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.
After that, you immediately have all the data and no more problems.
I think I will switch my spa communication to MQTT soon.

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

Control Topics
MQTT_Control

State Topics
MQTT_State

Example of a setpoint (the spa responds in one second)
MQTT_Set_Temp

IP and access data
IMG_3011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests