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

Checksum algorithm fails on 0xFF legitimate checksum #27

Closed
montgomeryb opened this issue Jun 26, 2023 · 2 comments · Fixed by #28
Closed

Checksum algorithm fails on 0xFF legitimate checksum #27

montgomeryb opened this issue Jun 26, 2023 · 2 comments · Fixed by #28
Assignees
Labels

Comments

@montgomeryb
Copy link

I have a cron job running that records the temperature and heats overnight. I am consistently getting exceptions thrown for a period because the checksum doesn't match.

I took the output from the exception below and ran it through the checksum as int function and it came back as zero, as you can see the spa returned it as 0xFF. If this is a legitimate issue, I am surprised it hasn't come up before although I am using Farenheit. Calling the function and ignoring the assertion for the assertion for the checksum the status below is reported. The spa I have is an SC-WF10.
I tried replicating the issue today with the same settings but was unable to get the code to fail. I have posted the failing bytes returned and the passing bytes returned below:

FFFF110F0107006400000085808085670000FF
FFFF110F01070064000000008080806700008A
{'power': True, 'filter': True, 'heater': True, 'jets': False, 'bubbles': False, 'sanitizer': False, 'unit': '°F', 'current_temp': 100, 'preset_temp': 103, 'error_code': False}

The bolded section is different, between the preset temperature and current temperature. I tried finding the intex protocol but I'm guessing it is by trial and error.  I'm not sure what is correcting the issue - it may be a scheduled event from the app that causes the temperature to update and a different checksum?
The only thing I found about 0 and FF checksums was in relation to UDP pstavirs/ostinato#160
I'm not sure how to work around this as I understand that every command issues a status to begin with? I have tried executing an async_update_info to see if that changes anything. 

Initializing IntexSpa instance...
IntexSpa instance initialized
'status' intent: Handling new intent...
'status' intent: a spa query is needed
'status' intent: new spa query...
Not connected to the spa, trying to connect...
Opening TCP connection with the spa at SPA_DEVICE:8990 with asyncio...
TCP connection established with the spa
Sending bytes to the spa: b'{"data": "8888060FEE0F01DA", "sid": "16877683219221", "type": 1}'
Receiving bytes from the spa: b'{"sid":"16877683219221","data":"FFFF110F0107006400000086808086680000FC","result":"ok","type":2}\n'
'status' intent: new status is rendered
'status' intent: Handling new intent...
'status' intent: a spa query is needed
'status' intent: new spa query...
Sending bytes to the spa: b'{"data": "8888060FEE0F01DA", "sid": "16877683220962", "type": 1}'
Receiving bytes from the spa: b'{"sid":"16877683220962","data":"FFFF110F0107006400000086808086680000FC","result":"ok","type":2}\n'
'status' intent: new status is rendered
'preset_temp' intent: Handling new intent...
'preset_temp' intent: triggering a preliminary 'update' intent...
'status' intent: Handling new intent...
'status' intent: a spa query is needed
'status' intent: new spa query...
Sending bytes to the spa: b'{"data": "8888060FEE0F01DA", "sid": "16877683221893", "type": 1}'
Receiving bytes from the spa: b'{"sid":"16877683221893","data":"FFFF110F0107006400000086808086680000FC","result":"ok","type":2}\n'
'status' intent: new status is rendered
'preset_temp' intent: a spa query is needed
'preset_temp' intent: new spa query...
Sending bytes to the spa: b'{"data": "8888050F0C6767", "sid": "16877683222765", "type": 1}'
Receiving bytes from the spa: b'{"sid":"16877683222765","data":"FFFF110F0107006400000085808085670000FF","result":"ok","type":2}\n'
Malformed spa response during spa querying
'preset_temp' intent: new spa query...
Sending bytes to the spa: b'{"data": "8888050F0C6767", "sid": "16877683247193", "type": 1}'
Receiving bytes from the spa: b'{"sid":"16877683247193","data":"FFFF110F0107006400000085808085670000FF","result":"ok","type":2}\n'
Malformed spa response during spa querying
'preset_temp' intent: new spa query...
Sending bytes to the spa: b'{"data": "8888050F0C6767", "sid": "16877683270894", "type": 1}'
Receiving bytes from the spa: b'{"sid":"16877683270894","data":"FFFF110F0107006400000085808085670000FF","result":"ok","type":2}\n'
Malformed spa response during spa querying
Spa is unreachable
@mathieu-mp
Copy link
Owner

Great analysis! I'll update the checksum functions.

You were out of luck with that 0xFF checksum: it is a simple addition of the data bits that has 1 in 256 chance on ending up on 0x00.

@mathieu-mp mathieu-mp added the Bug label Jul 1, 2023
@mathieu-mp mathieu-mp self-assigned this Jul 1, 2023
@mathieu-mp mathieu-mp linked a pull request Jul 2, 2023 that will close this issue
@mathieu-mp mathieu-mp changed the title Possible checksum anomaly? Checksum algorithm fails on 0xFF legitimate checksum Jul 2, 2023
@mathieu-mp
Copy link
Owner

Hi @montgomeryb

This shall be fixed with 0.8.4 Release

Please reopen the issue if it is not solved

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

Successfully merging a pull request may close this issue.

2 participants