From e53cdcc0720f11a9b800ce7b9dbb77bc3c54f900 Mon Sep 17 00:00:00 2001 From: Trammell Hudson Date: Mon, 31 Jan 2022 10:23:51 +0100 Subject: [PATCH] convert hcp xml into json for easier processing --- xml/dishwasher.json | 711 ++++++++++++++++++++++++++++++++++++++++++++ xml/hcpxml2json | 103 +++++++ 2 files changed, 814 insertions(+) create mode 100644 xml/dishwasher.json create mode 100755 xml/hcpxml2json diff --git a/xml/dishwasher.json b/xml/dishwasher.json new file mode 100644 index 0000000..626eb5b --- /dev/null +++ b/xml/dishwasher.json @@ -0,0 +1,711 @@ +{ + "description": { + "type": "Dishwasher", + "brand": "SIEMENS", + "model": "SX65EX56CN", + "version": "1", + "revision": "1" + }, + "status": { + "5": { + "name": "BSH.Common.Status.BackendConnected", + "access": "read", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "517": { + "name": "BSH.Common.Status.RemoteControlStartAllowed", + "access": "read", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "523": { + "name": "BSH.Common.Status.RemoteControlActive", + "access": "read", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "527": { + "name": "BSH.Common.Status.DoorState", + "access": "read", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Open", + "1": "Closed" + } + }, + "552": { + "name": "BSH.Common.Status.OperationState", + "access": "read", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Inactive", + "1": "Ready", + "2": "DelayedStart", + "3": "Run", + "4": "Pause", + "5": "ActionRequired", + "6": "Finished", + "7": "Error", + "8": "Aborting" + } + }, + "592": { + "name": "BSH.Common.Status.SoftwareUpdateTransactionID", + "access": "read", + "available": "true", + "refCID": "26", + "refDID": "83" + }, + "4096": { + "name": "Dishcare.Dishwasher.Status.ProgramPhase", + "access": "read", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "None", + "1": "PreRinse", + "2": "MainWash", + "3": "FinalRinse", + "4": "Drying" + } + }, + "4101": { + "name": "Dishcare.Dishwasher.Status.SilenceOnDemandRemainingTime", + "access": "read", + "available": "true", + "refCID": "10", + "refDID": "82" + }, + "4103": { + "name": "Dishcare.Dishwasher.Status.EcoDryActive", + "access": "read", + "available": "true", + "refCID": "01", + "refDID": "00" + } + }, + "settings": { + "3": { + "name": "BSH.Common.Setting.AllowBackendConnection", + "access": "readWrite", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "539": { + "name": "BSH.Common.Setting.PowerState", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "1": "Off", + "2": "On" + } + }, + "15": { + "name": "BSH.Common.Setting.RemoteControlLevel", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Monitoring", + "1": "ManualRemoteStart", + "2": "PermanentRemoteStart" + } + }, + "4354": { + "name": "Dishcare.Dishwasher.Setting.RinseAid", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "R01", + "2": "R02", + "3": "R03", + "4": "R04", + "5": "R05", + "6": "R06" + } + }, + "4356": { + "name": "Dishcare.Dishwasher.Setting.ExtraDry", + "access": "readWrite", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "4382": { + "name": "Dishcare.Dishwasher.Setting.SilenceOnDemandDefaultTime", + "access": "readWrite", + "available": "true", + "max": "1800", + "min": "60", + "refCID": "10", + "refDID": "82", + "stepSize": "60" + }, + "4355": { + "name": "Dishcare.Dishwasher.Setting.SensitivityTurbidity", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Standard", + "1": "Sensitive", + "2": "VerySensitive" + } + }, + "4357": { + "name": "Dishcare.Dishwasher.Setting.HotWater", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "ColdWater", + "1": "HotWater" + } + }, + "4362": { + "name": "Dishcare.Dishwasher.Setting.TimeLight", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "On" + } + }, + "4363": { + "name": "Dishcare.Dishwasher.Setting.EcoAsDefault", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "LastProgram", + "1": "EcoAsDefault" + } + }, + "4364": { + "name": "Dishcare.Dishwasher.Setting.SoundLevelSignal", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Low", + "2": "Medium", + "3": "High" + } + }, + "4365": { + "name": "Dishcare.Dishwasher.Setting.SoundLevelKey", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Low", + "2": "Medium", + "3": "High" + } + }, + "4367": { + "name": "Dishcare.Dishwasher.Setting.WaterHardness", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "H00", + "1": "H01", + "2": "H02", + "3": "H03", + "4": "H04", + "5": "H05", + "6": "H06", + "7": "H07" + } + }, + "4381": { + "name": "Dishcare.Dishwasher.Setting.DryingAssistantAllPrograms", + "access": "readWrite", + "available": "true", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "AllPrograms", + "2": "EcoAsDefault" + } + }, + "4384": { + "name": "Dishcare.Dishwasher.Setting.SpeedOnDemand", + "access": "read", + "available": "false", + "refCID": "01", + "refDID": "00" + } + }, + "events": { + "21": { + "name": "BSH.Common.Event.SoftwareUpdateAvailable", + "handling": "acknowledge", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "46": { + "name": "BSH.Common.Event.ConfirmPermanentRemoteStart", + "handling": "none", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "525": { + "name": "BSH.Common.Event.AquaStopOccured", + "handling": "none", + "level": "critical", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "540": { + "name": "BSH.Common.Event.ProgramFinished", + "handling": "none", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "543": { + "name": "BSH.Common.Event.LowWaterPressure", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "545": { + "name": "BSH.Common.Event.ProgramAborted", + "handling": "acknowledge", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "577": { + "name": "BSH.Common.Event.ConnectLocalWiFi", + "handling": "none", + "level": "warning", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "593": { + "name": "BSH.Common.Event.SoftwareDownloadAvailable", + "handling": "acknowledge", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "595": { + "name": "BSH.Common.Event.SoftwareUpdateSuccessful", + "handling": "acknowledge", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4608": { + "name": "Dishcare.Dishwasher.Event.InternalError", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4609": { + "name": "Dishcare.Dishwasher.Event.CheckFilterSystem", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4610": { + "name": "Dishcare.Dishwasher.Event.DrainingNotPossible", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4611": { + "name": "Dishcare.Dishwasher.Event.DrainPumpBlocked", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4612": { + "name": "Dishcare.Dishwasher.Event.WaterheaterCalcified", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4613": { + "name": "Dishcare.Dishwasher.Event.LowVoltage", + "handling": "none", + "level": "alert", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4625": { + "name": "Dishcare.Dishwasher.Event.RinseAidLack", + "handling": "none", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4627": { + "name": "Dishcare.Dishwasher.Event.RinseAidNearlyEmpty", + "handling": "none", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4624": { + "name": "Dishcare.Dishwasher.Event.SaltLack", + "handling": "none", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4626": { + "name": "Dishcare.Dishwasher.Event.SaltNearlyEmpty", + "handling": "none", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + }, + "4628": { + "name": "Dishcare.Dishwasher.Event.MachineCareReminder", + "handling": "acknowledge", + "level": "hint", + "refCID": "03", + "refDID": "80", + "values": { + "0": "Off", + "1": "Present", + "2": "Confirmed" + } + } + }, + "commands": { + "1": { + "name": "BSH.Common.Command.DeactivateWiFi", + "access": "writeOnly", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "6": { + "name": "BSH.Common.Command.AcknowledgeEvent", + "access": "writeOnly", + "available": "true", + "refCID": "15", + "refDID": "81" + }, + "16": { + "name": "BSH.Common.Command.RejectEvent", + "access": "writeOnly", + "available": "true", + "refCID": "15", + "refDID": "81" + }, + "512": { + "name": "BSH.Common.Command.AbortProgram", + "access": "none", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "553": { + "name": "BSH.Common.Command.ApplyFactoryReset", + "access": "writeOnly", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "555": { + "name": "BSH.Common.Command.DeactivateRemoteControlStart", + "access": "writeOnly", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "575": { + "name": "BSH.Common.Command.AllowSoftwareUpdateLocalWiFi", + "access": "writeOnly", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "594": { + "name": "BSH.Common.Command.AllowSoftwareDownload", + "access": "writeOnly", + "available": "true", + "refCID": "01", + "refDID": "00" + }, + "556": { + "name": "BSH.Common.Command.SetWaterHardness", + "access": "writeOnly", + "available": "true", + "refCID": "18", + "refDID": "81" + }, + "4864": { + "name": "Dishcare.Dishwasher.Command.StoreAsFavorite", + "access": "writeOnly", + "available": "true", + "refCID": "01", + "refDID": "00" + } + }, + "options": { + "542": { + "name": "BSH.Common.Option.ProgramProgress", + "access": "read", + "available": "true", + "refCID": "11", + "refDID": "A0" + }, + "544": { + "name": "BSH.Common.Option.RemainingProgramTime", + "access": "read", + "available": "true", + "refCID": "10", + "refDID": "82" + }, + "549": { + "name": "BSH.Common.Option.RemainingProgramTimeIsEstimated", + "access": "read", + "available": "true", + "initValue": "1", + "refCID": "01", + "refDID": "00" + }, + "558": { + "name": "BSH.Common.Option.StartInRelative", + "access": "read", + "available": "true", + "max": "86400", + "min": "0", + "refCID": "10", + "refDID": "82" + }, + "561": { + "name": "BSH.Common.Option.EnergyForecast", + "access": "read", + "available": "true", + "refCID": "11", + "refDID": "A0" + }, + "562": { + "name": "BSH.Common.Option.WaterForecast", + "access": "read", + "available": "true", + "refCID": "11", + "refDID": "A0" + }, + "5136": { + "name": "Dishcare.Dishwasher.Option.SilenceOnDemand", + "access": "readWrite", + "available": "true", + "default": "false", + "refCID": "01", + "refDID": "00" + }, + "5124": { + "name": "Dishcare.Dishwasher.Option.HalfLoad", + "access": "readWrite", + "available": "true", + "default": "false", + "refCID": "01", + "refDID": "00" + }, + "5126": { + "name": "Dishcare.Dishwasher.Option.IntensivZone", + "access": "readWrite", + "available": "true", + "default": "false", + "refCID": "01", + "refDID": "00" + }, + "5127": { + "name": "Dishcare.Dishwasher.Option.VarioSpeedPlus", + "access": "readWrite", + "available": "true", + "default": "false", + "refCID": "01", + "refDID": "00" + } + }, + "errors": { + "200": "BSH.Common.Error.200.OK", + "202": "BSH.Common.Error.202.Accepted", + "400": "BSH.Common.Error.400.BadRequest", + "403": "BSH.Common.Error.403.Forbidden", + "404": "BSH.Common.Error.404.NotFound", + "405": "BSH.Common.Error.405.MethodNotAllowed", + "413": "BSH.Common.Error.413.RequestEntityTooLong", + "412": "BSH.Common.Error.414.RequestUriTooLong", + "429": "BSH.Common.Error.429.TooManyRequests", + "500": "BSH.Common.Error.500.InternalServerError", + "501": "BSH.Common.Error.501.NotImplemented", + "502": "BSH.Common.Error.502.BadGateway", + "503": "BSH.Common.Error.503.ServiceUnavailable", + "504": "BSH.Common.Error.504.GatewayTimeout", + "507": "BSH.Common.Error.507.InsufficientMemory", + "542": "BSH.Common.Error.BackendNotConnected", + "515": "BSH.Common.Error.Busy", + "535": "BSH.Common.Error.CmdViolation", + "540": "BSH.Common.Error.DeviceStateNotCompliant", + "543": "BSH.Common.Error.EnergyManagementNotConnected", + "533": "BSH.Common.Error.Incomplete", + "534": "BSH.Common.Error.Inconsistent", + "536": "BSH.Common.Error.InvalidFormat", + "532": "BSH.Common.Error.InvalidUIDValue", + "539": "BSH.Common.Error.LockedByLocalControl", + "518": "BSH.Common.Error.NoAccess", + "521": "BSH.Common.Error.NoAccessByList", + "530": "BSH.Common.Error.NoExecution", + "524": "BSH.Common.Error.NotAvailable", + "527": "BSH.Common.Error.NotAvailableByList", + "544": "BSH.Common.Error.NotInLocalWiFi", + "541": "BSH.Common.Error.ProcessStateNotCompliant", + "517": "BSH.Common.Error.ReadRequest.Busy", + "520": "BSH.Common.Error.ReadRequest.NoAccess", + "523": "BSH.Common.Error.ReadRequest.NoAccessByList", + "526": "BSH.Common.Error.ReadRequest.NotAvailable", + "529": "BSH.Common.Error.ReadRequest.NotAvailableByList", + "514": "BSH.Common.Error.ReadRequest.UnknownUID", + "537": "BSH.Common.Error.RemoteControlNotActive", + "538": "BSH.Common.Error.RemoteStartNotActive", + "512": "BSH.Common.Error.UnknownUID", + "531": "BSH.Common.Error.ValueOutOfRange", + "516": "BSH.Common.Error.WriteRequest.Busy", + "519": "BSH.Common.Error.WriteRequest.NoAccess", + "522": "BSH.Common.Error.WriteRequest.NoAccessByList", + "525": "BSH.Common.Error.WriteRequest.NotAvailable", + "528": "BSH.Common.Error.WriteRequest.NotAvailableByList", + "513": "BSH.Common.Error.WriteRequest.UnknownUID" + } +} diff --git a/xml/hcpxml2json b/xml/hcpxml2json new file mode 100755 index 0000000..03f2be1 --- /dev/null +++ b/xml/hcpxml2json @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +# Convert the featuremap and devicedescription XML files into a single JSON +# this collapses the XML entities and duplicates some things, but makes for +# easier parsing later +# +# Program groups are ignored for now +# + +import sys +import xml.etree.ElementTree as ET +import json + +# the feature file has features, errors, and enums +# for now the ordering is hardcoded +featuremapping = ET.parse(sys.argv[1]).getroot() +description = ET.parse(sys.argv[2]).getroot() + +##################### +# +# Parse the feature file +# + +features = {} +errors = {} +enums = {} + +# Features +for child in featuremapping[1]: #.iter('feature'): + uid = int(child.attrib["refUID"], 16) + name = child.text + features[uid] = name + +# Errors +for child in featuremapping[2]: + uid = int(child.attrib["refEID"], 16) + name = child.text + errors[uid] = name + +# Enums +for child in featuremapping[3]: + uid = int(child.attrib["refENID"], 16) + enum_name = child.attrib["enumKey"] + values = {} + for v in child: + value = int(v.attrib["refValue"]) + name = v.text + values[value] = name + enums[uid] = { + "name": enum_name, + "values": values, + } + +##################### +# +# Parse the description file +# + +def parse_xml_list(entries): + parsed = {} + + for el in entries: + # not sure how to parse refCID and refDID + uid = int(el.attrib["uid"], 16) + data = { + "name": features[uid], + } + + for key in el.attrib: + data[key] = el.attrib[key] + + # clean up + del data["uid"] + + if "enumerationType" in el.attrib: + del data["enumerationType"] + enum_id = int(el.attrib["enumerationType"], 16) + data["values"] = enums[enum_id]["values"] + + parsed[uid] = data + + return parsed + +def parse_machine_description(entries): + description = {} + + for el in entries: + prefix, has_namespace, tag = el.tag.partition('}') + if tag != "pairableDeviceTypes": + description[tag] = el.text + + return description + +machine = { + "description": parse_machine_description(description[3]), + "status": parse_xml_list(description[4]), + "settings": parse_xml_list(description[5]), + "events": parse_xml_list(description[6]), + "commands": parse_xml_list(description[7]), + "options": parse_xml_list(description[8]), + "errors": errors, +} + +print(json.dumps(machine))