diff --git a/miio/airconditioningcompanion.py b/miio/airconditioningcompanion.py index 386850135..289fec35a 100644 --- a/miio/airconditioningcompanion.py +++ b/miio/airconditioningcompanion.py @@ -265,9 +265,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirConditioningCompanion(Device): """Main class representing Xiaomi Air Conditioning Companion V1 and V2.""" diff --git a/miio/airconditioningcompanionMCN.py b/miio/airconditioningcompanionMCN.py index 16106d1cd..9727a0304 100644 --- a/miio/airconditioningcompanionMCN.py +++ b/miio/airconditioningcompanionMCN.py @@ -118,9 +118,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirConditioningCompanionMcn02(Device): """Main class representing Xiaomi Air Conditioning Companion V1 and V2.""" diff --git a/miio/airdehumidifier.py b/miio/airdehumidifier.py index 5efdadd4f..53567b7d4 100644 --- a/miio/airdehumidifier.py +++ b/miio/airdehumidifier.py @@ -184,9 +184,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirDehumidifier(Device): """Implementation of Xiaomi Mi Air Dehumidifier.""" diff --git a/miio/airfresh.py b/miio/airfresh.py index 32dfbc8a2..2a2f23b39 100644 --- a/miio/airfresh.py +++ b/miio/airfresh.py @@ -257,9 +257,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirFresh(Device): """Main class representing the air fresh.""" diff --git a/miio/airfresh_t2017.py b/miio/airfresh_t2017.py index cbadfa37f..e7f413d85 100644 --- a/miio/airfresh_t2017.py +++ b/miio/airfresh_t2017.py @@ -230,9 +230,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirFreshT2017(Device): """Main class representing the air fresh t2017.""" diff --git a/miio/airhumidifier.py b/miio/airhumidifier.py index 4ebc359f1..d023a33ef 100644 --- a/miio/airhumidifier.py +++ b/miio/airhumidifier.py @@ -248,9 +248,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirHumidifier(Device): """Implementation of Xiaomi Mi Air Humidifier.""" diff --git a/miio/airhumidifier_jsq.py b/miio/airhumidifier_jsq.py index 3e17ff429..b2d7288ee 100644 --- a/miio/airhumidifier_jsq.py +++ b/miio/airhumidifier_jsq.py @@ -151,9 +151,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirHumidifierJsq(Device): """ diff --git a/miio/airhumidifier_miot.py b/miio/airhumidifier_miot.py index 727044da7..97d863b48 100644 --- a/miio/airhumidifier_miot.py +++ b/miio/airhumidifier_miot.py @@ -241,9 +241,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirHumidifierMiot(MiotDevice): """Main class representing the air humidifier which uses MIoT protocol.""" diff --git a/miio/airhumidifier_mjjsq.py b/miio/airhumidifier_mjjsq.py index c7f0d9a33..22d226b22 100644 --- a/miio/airhumidifier_mjjsq.py +++ b/miio/airhumidifier_mjjsq.py @@ -128,9 +128,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirHumidifierMjjsq(Device): def __init__( diff --git a/miio/airpurifier.py b/miio/airpurifier.py index cd7d360d8..1255ed49f 100644 --- a/miio/airpurifier.py +++ b/miio/airpurifier.py @@ -334,9 +334,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirPurifier(Device): """Main class representing the air purifier.""" diff --git a/miio/airpurifier_miot.py b/miio/airpurifier_miot.py index 00ceae706..031ae1aa3 100644 --- a/miio/airpurifier_miot.py +++ b/miio/airpurifier_miot.py @@ -248,9 +248,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirPurifierMiot(MiotDevice): """Main class representing the air purifier which uses MIoT protocol.""" diff --git a/miio/airqualitymonitor.py b/miio/airqualitymonitor.py index c4f9d7cbc..4ab8a9383 100644 --- a/miio/airqualitymonitor.py +++ b/miio/airqualitymonitor.py @@ -177,9 +177,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AirQualityMonitor(Device): """Xiaomi PM2.5 Air Quality Monitor.""" diff --git a/miio/aqaracamera.py b/miio/aqaracamera.py index c527c6179..dd70573bc 100644 --- a/miio/aqaracamera.py +++ b/miio/aqaracamera.py @@ -177,9 +177,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class AqaraCamera(Device): """Main class representing the Xiaomi Aqara Camera.""" diff --git a/miio/ceil.py b/miio/ceil.py index ae4d7644a..be8e3778f 100644 --- a/miio/ceil.py +++ b/miio/ceil.py @@ -87,9 +87,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class Ceil(Device): """Main class representing Xiaomi Philips LED Ceiling Lamp.""" diff --git a/miio/chuangmi_camera.py b/miio/chuangmi_camera.py index 97f3802ce..fa1185e82 100644 --- a/miio/chuangmi_camera.py +++ b/miio/chuangmi_camera.py @@ -178,9 +178,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class ChuangmiCamera(Device): """Main class representing the Xiaomi Chuangmi Camera.""" diff --git a/miio/chuangmi_plug.py b/miio/chuangmi_plug.py index 727a9e61d..16aaaa622 100644 --- a/miio/chuangmi_plug.py +++ b/miio/chuangmi_plug.py @@ -100,9 +100,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class ChuangmiPlug(Device): """Main class representing the Chuangmi Plug.""" diff --git a/miio/click_common.py b/miio/click_common.py index 406ddc075..f4bd291de 100644 --- a/miio/click_common.py +++ b/miio/click_common.py @@ -304,8 +304,11 @@ def wrap(*args, **kwargs): return get_json_data_func = getattr(result, "__json__", None) + data_variable = getattr(result, "data", None) if get_json_data_func is not None: result = get_json_data_func() + elif data_variable is not None: + result = data_variable click.echo(json.dumps(result, indent=indent)) return wrap diff --git a/miio/cooker.py b/miio/cooker.py index 7a2360908..14a01c761 100644 --- a/miio/cooker.py +++ b/miio/cooker.py @@ -146,9 +146,6 @@ def __repr__(self) -> str: s = "" % str(self.data) return s - def __json__(self): - return self.data - class CookerCustomizations: def __init__(self, custom: str): diff --git a/miio/device.py b/miio/device.py index 44062d62c..3cf3e4b69 100644 --- a/miio/device.py +++ b/miio/device.py @@ -55,9 +55,6 @@ def __repr__(self): self.data["token"], ) - def __json__(self): - return self.data - @property def network_interface(self): """Information about network configuration.""" diff --git a/miio/fan.py b/miio/fan.py index 1ba44c3a2..caef93606 100644 --- a/miio/fan.py +++ b/miio/fan.py @@ -272,9 +272,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class FanStatusP5: """Container for status reports from the Xiaomi Mi Smart Pedestal Fan DMaker P5.""" @@ -363,9 +360,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class Fan(Device): """Main class representing the Xiaomi Mi Smart Pedestal Fan.""" diff --git a/miio/heater.py b/miio/heater.py index 81f1dc207..92b7d7379 100644 --- a/miio/heater.py +++ b/miio/heater.py @@ -148,9 +148,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class Heater(Device): """Main class representing the Smartmi Zhimi Heater.""" diff --git a/miio/philips_bulb.py b/miio/philips_bulb.py index 32178aec8..a90d83eca 100644 --- a/miio/philips_bulb.py +++ b/miio/philips_bulb.py @@ -81,9 +81,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class PhilipsWhiteBulb(Device): """Main class representing Xiaomi Philips White LED Ball Lamp.""" diff --git a/miio/philips_eyecare.py b/miio/philips_eyecare.py index 15e677b70..830a29bb2 100644 --- a/miio/philips_eyecare.py +++ b/miio/philips_eyecare.py @@ -99,9 +99,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class PhilipsEyecare(Device): """Main class representing Xiaomi Philips Eyecare Smart Lamp 2.""" diff --git a/miio/philips_moonlight.py b/miio/philips_moonlight.py index 07dacb3e0..3646f4673 100644 --- a/miio/philips_moonlight.py +++ b/miio/philips_moonlight.py @@ -105,9 +105,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class PhilipsMoonlight(Device): """Main class representing Xiaomi Philips Zhirui Bedside Lamp. diff --git a/miio/philips_rwread.py b/miio/philips_rwread.py index 64148a7c2..ee02df70b 100644 --- a/miio/philips_rwread.py +++ b/miio/philips_rwread.py @@ -101,9 +101,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class PhilipsRwread(Device): """Main class representing Xiaomi Philips RW Read.""" diff --git a/miio/powerstrip.py b/miio/powerstrip.py index c7b9a293d..000e4c0a9 100644 --- a/miio/powerstrip.py +++ b/miio/powerstrip.py @@ -157,9 +157,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class PowerStrip(Device): """Main class representing the smart power strip.""" diff --git a/miio/pwzn_relay.py b/miio/pwzn_relay.py index e1badd63f..cc9ca4c34 100644 --- a/miio/pwzn_relay.py +++ b/miio/pwzn_relay.py @@ -102,9 +102,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class PwznRelay(Device): """Main class representing the PWZN Relay.""" diff --git a/miio/vacuumcontainers.py b/miio/vacuumcontainers.py index ab28a346e..47402673f 100644 --- a/miio/vacuumcontainers.py +++ b/miio/vacuumcontainers.py @@ -186,9 +186,6 @@ def __repr__(self) -> str: s += "cleaned %s m² in %s>" % (self.clean_area, self.clean_time) return s - def __json__(self): - return self.data - class CleaningSummary: """Contains summarized information about available cleaning runs.""" @@ -228,9 +225,6 @@ def __repr__(self) -> str: % (self.count, self.total_duration, self.total_area, self.ids) # noqa: E501 ) - def __json__(self): - return self.data - class CleaningDetails: """Contains details about a specific cleaning run.""" @@ -285,9 +279,6 @@ def __repr__(self) -> str: self.area, ) - def __json__(self): - return self.data - class ConsumableStatus: """Container for consumable status information, @@ -361,9 +352,6 @@ def __repr__(self) -> str: ) ) - def __json__(self): - return self.data - class DNDStatus: """A container for the do-not-disturb status.""" @@ -395,9 +383,6 @@ def __repr__(self): self.end, ) - def __json__(self): - return self.data - class Timer: """A container for scheduling. @@ -454,9 +439,6 @@ def __repr__(self) -> str: self.cron, ) - def __json__(self): - return self.data - class SoundStatus: """Container for sound status.""" @@ -479,9 +461,6 @@ def __repr__(self): self.being_installed, ) - def __json__(self): - return self.data - class SoundInstallState(IntEnum): Unknown = 0 @@ -544,9 +523,6 @@ def __repr__(self) -> str: " - progress: %s>" % (self.sid, self.state, self.error, self.progress) ) - def __json__(self): - return self.data - class CarpetModeStatus: """Container for carpet mode status.""" @@ -590,6 +566,3 @@ def __repr__(self): self.current_integral, ) ) - - def __json__(self): - return self.data diff --git a/miio/viomivacuum.py b/miio/viomivacuum.py index 8405fd79c..3d032d7ed 100644 --- a/miio/viomivacuum.py +++ b/miio/viomivacuum.py @@ -100,9 +100,6 @@ def __repr__(self) -> str: ) ) - def __json__(self): - return self.data - class ViomiVacuumSpeed(Enum): Silent = 0 diff --git a/miio/waterpurifier.py b/miio/waterpurifier.py index 312994c28..882527cf0 100644 --- a/miio/waterpurifier.py +++ b/miio/waterpurifier.py @@ -130,9 +130,6 @@ def __repr__(self) -> str: ) ) - def __json__(self): - return self.data - class WaterPurifier(Device): """Main class representing the waiter purifier.""" diff --git a/miio/wifirepeater.py b/miio/wifirepeater.py index aa6025180..eac3e1acd 100644 --- a/miio/wifirepeater.py +++ b/miio/wifirepeater.py @@ -46,9 +46,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class WifiRepeaterConfiguration: def __init__(self, data): @@ -79,9 +76,6 @@ def __repr__(self) -> str: ) return s - def __json__(self): - return self.data - class WifiRepeater(Device): """Device class for Xiaomi Mi WiFi Repeater 2.""" diff --git a/miio/wifispeaker.py b/miio/wifispeaker.py index 9de9e7ede..0dbfb6d46 100644 --- a/miio/wifispeaker.py +++ b/miio/wifispeaker.py @@ -117,9 +117,6 @@ def __repr__(self) -> str: return s - def __json__(self): - return self.data - class WifiSpeaker(Device): """Device class for Xiaomi Smart Wifi Speaker."""