Skip to content

Devices data being set with invalid values on update, causing errors with setting switches and lights #115

Closed
anderjoshai wants to merge 5 commits intoflz:masterfrom
anderjoshai:master
Closed

Devices data being set with invalid values on update, causing errors with setting switches and lights #115
anderjoshai wants to merge 5 commits intoflz:masterfrom
anderjoshai:master

Conversation

@anderjoshai
Copy link
Copy Markdown

This applies to the iaqua system, a similar fix may be needed for other systems
This resolves the open HA error described here: home-assistant/core#156960

The library will sometimes fail to set the value of lights and switches with the error "'NaN' is not a valid Aqualink state"
This is a result of the Jandy api returning garbage values for about 30 seconds after a light related command is received. Until the garbage values are overwritten by a valid update, all the devices will have invalid states and properties, leading to various errors.

Here is what the update from the API looks like after turning a light on or off:

Devices response: {'message': '', 'devices_screen': [{'status': 'Online'}, {'response': "AQU='70','0C 00 01 02 03 05 06 07 0E 0F 1A 20 21 00 03 00 03 00 58 00 46 00 51 00 00 00 42 30 33 31 36 38 32 33 20 52 53 2D 34 20 43 6F 6D 62 6F 00 00'"}, {'group': '1'}, {'aux_': [{'state': '0'}, {'label': 'AUX '}, {'icon': 'aux_3_0.png'}, {'type': '0'}, {'subtype': '3'}]}, {'aux_1': [{'state': '88'}, {'label': 'AUX 1'}, {'icon': 'aux_0_88.png'}, {'type': '70'}, {'subtype': '0'}]}, {'aux_2': [{'state': 'NaN'}, {'label': 'AUX 2'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_3': [{'state': 'NaN'}, {'label': 'AUX 3'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_5': [{'state': 'NaN'}, {'label': 'AUX 5'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_6': [{'state': 'NaN'}, {'label': 'AUX 6'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_7': [{'state': 'NaN'}, {'label': 'AUX 7'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_B7': [{'state': 'NaN'}, {'label': 'AUX B7'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_B8': [{'state': 'NaN'}, {'label': 'AUX B8'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_D3': [{'state': 'NaN'}, {'label': 'AUX D3'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_C5': [{'state': 'NaN'}, {'label': 'AUX C5'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}, {'aux_C6': [{'state': 'NaN'}, {'label': 'AUX C6'}, {'icon': 'aux_NaN_NaN.png'}, {'type': 'NaN'}, {'subtype': 'NaN'}]}], 'icl_info_list': []}

Home response: {'message': '', 'serial': 'QT75K6NQJGGB', 'home_screen': [{'status': 'Online'}, {'response': "AQU='72','32|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|0|1|0|0|Flood Light|1|1|1|100|Beach Light|1|7|2|1|Aux3|0|1|0|2|Aux V1|0|1|0|2|Aux V2|0|1|0|2|Aux V3|0|1|0|2|Aux V4|1|1|0|2|Aux V5|1|1|0|2|Aux V6|0|1|0|2|Aux V7|0|1|0|2|Aux V8|0|1|0|2|Aux V9|0|1|0|2|Aux V10|0|1|0|2|Aux V11|0|1|0|2|Aux V12|0|1|0|2|Aux V13|0|1|0|2|Aux V14|0|1|0|2|Aux V15|0|1|0|2|Aux V16|0|1|0|2|Aux V17|0|1|0|2|Aux V18|0|1|0|2|Aux V19|1|1|0|2|Aux V20|1|1|0|2|Aux V21|1|1|0|2|Aux V22|1|1|0|2|Aux V23|1|1|0|2|Aux V24|1|1|0|2|Aux V25|1|1|0|2|Aux V26|0|1|0|2|Aux V27|0|1|0|2|Aux V28|1|1|0|0|Extra Aux'"}, {'system_type': ''}, {'temp_scale': ''}, {'spa_temp': ''}, {'pool_temp': ''}, {'air_temp': ''}, {'spa_set_point': ''}, {'pool_set_point': ''}, {'cover_pool': ''}, {'freeze_protection': ''}, {'spa_pump': ''}, {'pool_pump': ''}, {'spa_heater': ''}, {'pool_heater': ''}, {'solar_heater': ''}, {'spa_salinity': ''}, {'pool_salinity': ''}, {'orp': ''}, {'ph': ''}, {'is_icl_present': 'absent'}, {'icl_custom_color_info': []}, {'heatpump_info': {}}, {'pool_chill_set_point': ''}, {'swc_info': {'isswcPresent': False}}, {'relay_count': ''}]}

The fix validates the update data in system.py before assigning it to a device's data field. This way it will never leave a device in an invalid state, instead it will preserve the last known valid state of the device until a valid update is received.

Confidence Testing:
I ran this change on my local HA system and none of the lights and switches commands failed, and I did not encounter any errors.

Ensure 'state' value is valid aqualink state before updating device data.
Updated validation logic to allow empty updates for 'spa_temp' and 'pool_temp'. Removed redundant state validation checks.
Removed the validate_update_data method from the system class.
@anderjoshai anderjoshai closed this Mar 3, 2026
@flz
Copy link
Copy Markdown
Owner

flz commented Mar 3, 2026

@anderjoshai Apologies for the radio silence. Is this not relevant anymore?

@anderjoshai
Copy link
Copy Markdown
Author

@anderjoshai Apologies for the radio silence. Is this not relevant anymore?

Hi @flz, no worries, happy to hear from you! This issue is indeed still relevant. I created an updated PR for it here #116
It would be great if you could review and approve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants