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

fix: Resolve every enum there is in the xml blobs #105

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

Hypfer
Copy link
Contributor

@Hypfer Hypfer commented Oct 30, 2024

I've noticed that nested enums did not get resolved correctly by the currently rather hackish XML2JSON parser.

With these changes, they now do, greatly improving the HA experience for my washing machine & dryer:

image
image

In the future, it should probably become a real parser that actually understands the format, however for now, I suppose this is good enough

@pmagyar pmagyar requested review from Meatballs1 and pmagyar November 4, 2024 14:02
@Meatballs1
Copy link
Collaborator

Meatballs1 commented Nov 6, 2024

I haven't touched this bit of python from the import of the original project but the logic looks OK.

I don't get any new definitions for any of my devices when I run this versus the old code. I don't suppose you could just provide an example of the XML which gets missed just to help document the issue?

I did notice that I have a few new definitions from just re-requesting my devices.json as my Dishwasher had an update and the version in the json has gone from 4.0 to 5.1.

@Hypfer
Copy link
Contributor Author

Hypfer commented Nov 6, 2024

I don't suppose you could just provide an example of the XML which gets missed just to help document the issue?

Come to think of it, I guess it would indeed make a lot of sense to collect these zips the login script downloads and build some test cases out of them.

There you go

Siemens_WQ46B2C40_Dryer.zip
Siemens_SN45ZS49CE_Dishwasher.zip
Siemens_WG44B2A40_Washer.zip

The one that prompted this PR was this one which can be found in the Washer zip:

	<!--BSH.Common.Root.OptionList -->
	<optionList access="readWrite" available="true" uid="0106">
		<!--BSH.Common.Option.EstimatedTotalProgramTime -->
		<option access="read" available="true" initValue="0" min="0" notifyOnChange="true" refCID="10" refDID="82" stepSize="60" uid="0213"/>
		<!--LaundryCare.Common.OptionList.ActiveStatus -->
		<optionList access="none" available="true" uid="161B">
			<!--BSH.Common.Option.ProgramProgress -->
			<option access="none" available="false" initValue="0.0" notifyOnChange="true" refCID="11" refDID="A0" stepSize="1.0" uid="021E"/>
			<!--BSH.Common.Option.RemainingProgramTime -->
			<option access="none" available="true" initValue="0" max="21600" min="0" notifyOnChange="true" refCID="10" refDID="82" stepSize="60" uid="0220"/>
			<!--BSH.Common.Option.RemainingProgramTimeIsEstimated -->
			<option access="read" available="true" initValue="true" notifyOnChange="true" refCID="01" refDID="00" uid="0225"/>
			<!--LaundryCare.Common.Option.ProcessPhase -->
			<option access="none" available="false" enumerationType="6A06" initValue="0" max="128" min="0" notifyOnChange="true" refCID="03" refDID="81" uid="6A06"/>
		</optionList>

Specifically the ProcessPhase

@Meatballs1
Copy link
Collaborator

Awesome, I guess a before and after devices.json output for the above too would be useful to see. Does the output get nested or flattened in the JSON?

@pmagyar this didn't break anything for me but I cant find any nested optionLists for any of my appliances so it would be good if someone else could just double check it doesn't break things for them. Other than that I think it's OK to merge?

@Hypfer
Copy link
Contributor Author

Hypfer commented Nov 8, 2024

@Meatballs1 It stays flat, but it turns from

            "27138": {
                "name": "LaundryCare.Common.Option.LoadRecommendation"
            },
            "27142": {
                "name": "LaundryCare.Common.Option.ProcessPhase"
            },

to

            "27138": {
                "name": "LaundryCare.Common.Option.LoadRecommendation",
                "access": "none",
                "available": "false",
                "initValue": "0",
                "max": "25500",
                "min": "0",
                "notifyOnChange": "true",
                "refCID": "13",
                "refDID": "81",
                "stepSize": "100"
            },
            "27142": {
                "name": "LaundryCare.Common.Option.ProcessPhase",
                "access": "none",
                "available": "false",
                "initValue": "0",
                "max": "128",
                "min": "0",
                "notifyOnChange": "true",
                "refCID": "03",
                "refDID": "81",
                "values": {
                    "0": "NoPhase",
                    "1": "Prewash",
                    "2": "IntermediateSpin",
                    "3": "FillingDetergent",
                    "4": "DetectingLoad",
[...]
                    "128": "AnyPhase"
                }
            },

@adec
Copy link

adec commented Nov 25, 2024

The one that prompted this PR was this one which can be found in the Washer zip:

	<!--BSH.Common.Root.OptionList -->
	<optionList access="readWrite" available="true" uid="0106">
		<!--BSH.Common.Option.EstimatedTotalProgramTime -->
		<option access="read" available="true" initValue="0" min="0" notifyOnChange="true" refCID="10" refDID="82" stepSize="60" uid="0213"/>
		<!--LaundryCare.Common.OptionList.ActiveStatus -->
		<optionList access="none" available="true" uid="161B">
			<!--BSH.Common.Option.ProgramProgress -->
			<option access="none" available="false" initValue="0.0" notifyOnChange="true" refCID="11" refDID="A0" stepSize="1.0" uid="021E"/>
			<!--BSH.Common.Option.RemainingProgramTime -->
			<option access="none" available="true" initValue="0" max="21600" min="0" notifyOnChange="true" refCID="10" refDID="82" stepSize="60" uid="0220"/>
			<!--BSH.Common.Option.RemainingProgramTimeIsEstimated -->
			<option access="read" available="true" initValue="true" notifyOnChange="true" refCID="01" refDID="00" uid="0225"/>
			<!--LaundryCare.Common.Option.ProcessPhase -->
			<option access="none" available="false" enumerationType="6A06" initValue="0" max="128" min="0" notifyOnChange="true" refCID="03" refDID="81" uid="6A06"/>
		</optionList>

Specifically the ProcessPhase

I wish I'd spotted this PR yesterday as I spent the evening debugging the issue myself as I was having similar problems with my Bosch Washer & Dryer. I was just about to submit a PR but then spotted yours - and our code is almost the same. 🤣

@Meatballs1 Meatballs1 merged commit 870142d into hcpy2-0:main Nov 29, 2024
2 checks passed
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.

4 participants