panasonic-comfort-cloud-client icon indicating copy to clipboard operation
panasonic-comfort-cloud-client copied to clipboard

Added human readable JSON output for Device

Open lostfields opened this issue 1 year ago • 2 comments

Human readable device information, instead of displaying enum values it will output enum key when JSON serializing the objects. Device setters also supports enum key.

image

lostfields avatar Dec 09 '24 08:12 lostfields

Earlier, JSON.stringify(groups) outputted

[{
  "_id":8440,
  "_name":"My House",
  "_devices":[{"_guid":"***","_name":"***","_operate":1,"_operationMode":3,"_temperatureSet":21,"_fanSpeed":0,"_fanAutoMode":3,"_airSwingLR":2,"_airSwingUD":2,"_ecoMode":0,"_actualNanoe":0,"_ecoNavi":0,"_nanoe":1,"_iAuto":0,"_airDirection":0,"_ecoFunctionData":0,"_insideTemperature":0,"_outTemperature":0,"lastSettingMode":0}]
}]

and now

[{
  "id":8440,
  "name":"My House",
  "devices":[{"guid":"***","name":"***","operate":"On","operationMode":"Heat","temperatureSet":21,"fanSpeed":"Auto","fanAutoMode":"AirSwingLR","airSwingLR":"Mid","airSwingUD":"Mid","ecoMode":"Auto","ecoNavi":0,"nanoe":"Off","iAuto":0,"actualNanoe":0,"airDirection":0,"ecoFunctionData":0,"insideTemperature":0,"outTemperature":0}]
}]

That may be a breaking change, it depends. Although it's more correct to do it this way since the serialized value is the same as the class definition.

lostfields avatar Dec 10 '24 12:12 lostfields

I've made it backwards compatible now, it will output the same as before with no breaking changes. To get the new output you have to set ComfortCloudClient.outputMode = 'pretty'

What do you think @marc2016 ?

lostfields avatar Jan 03 '25 19:01 lostfields