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

Force parameters to be an empty list if none is given #408

Merged
merged 2 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions miio/airconditioningcompanion.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class AirConditioningCompanion(Device):
)
def status(self) -> AirConditioningCompanionStatus:
"""Return device status."""
status = self.send("get_model_and_state", [])
status = self.send("get_model_and_state")
return AirConditioningCompanionStatus(status)

@command(
Expand Down Expand Up @@ -298,7 +298,7 @@ def learn(self, slot: int=STORAGE_SLOT_ID):
)
def learn_result(self):
"""Read the learned command."""
return self.send("get_ir_learn_result", [])
return self.send("get_ir_learn_result")

@command(
click.argument("slot", type=int),
Expand Down
10 changes: 5 additions & 5 deletions miio/chuangmi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def status(self) -> ChuangmiPlugStatus:
properties_count, values_count)

if self.model == MODEL_CHUANGMI_PLUG_V3:
load_power = self.send("get_power", []) # Response: [300]
load_power = self.send("get_power") # Response: [300]
if len(load_power) == 1:
properties.append('load_power')
values.append(load_power[0] * 0.01)
Expand All @@ -145,7 +145,7 @@ def status(self) -> ChuangmiPlugStatus:
def on(self):
"""Power on."""
if self.model == MODEL_CHUANGMI_PLUG_V1:
return self.send("set_on", [])
return self.send("set_on")

return self.send("set_power", ["on"])

Expand All @@ -155,7 +155,7 @@ def on(self):
def off(self):
"""Power off."""
if self.model == MODEL_CHUANGMI_PLUG_V1:
return self.send("set_off", [])
return self.send("set_off")

return self.send("set_power", ["off"])

Expand All @@ -164,14 +164,14 @@ def off(self):
)
def usb_on(self):
"""Power on."""
return self.send("set_usb_on", [])
return self.send("set_usb_on")

@command(
default_output = format_output("Powering USB off"),
)
def usb_off(self):
"""Power off."""
return self.send("set_usb_off", [])
return self.send("set_usb_off")

@command(
click.argument("wifi_led", type=bool),
Expand Down
2 changes: 1 addition & 1 deletion miio/cooker.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ def get_temperature_history(self) -> TemperatureHistory:
The temperature is only available while cooking.
Approx. six data points per minute.
"""
data = self.send('get_temp_history', [])
data = self.send('get_temp_history')

return TemperatureHistory(data[0])

Expand Down
8 changes: 5 additions & 3 deletions miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ def send(self, command: str, parameters: Any=None, retry_count=3) -> Any:

if parameters is not None:
cmd["params"] = parameters
else:
cmd["params"] = []

send_ts = self._device_ts + datetime.timedelta(seconds=1)
header = {'length': 0, 'unknown': 0x00000000,
Expand Down Expand Up @@ -314,7 +316,7 @@ def info(self) -> DeviceInfo:
"""Get miIO protocol information from the device.
This includes information about connected wlan network,
and harware and software versions."""
return DeviceInfo(self.send("miIO.info", []))
return DeviceInfo(self.send("miIO.info"))

def update(self, url: str, md5: str):
"""Start an OTA update."""
Expand All @@ -329,11 +331,11 @@ def update(self, url: str, md5: str):

def update_progress(self) -> int:
"""Return current update progress [0-100]."""
return self.send("miIO.get_ota_progress", [])[0]
return self.send("miIO.get_ota_progress")[0]

def update_state(self):
"""Return current update state."""
return UpdateState(self.send("miIO.get_ota_state", [])[0])
return UpdateState(self.send("miIO.get_ota_state")[0])

def configure_wifi(self, ssid, password, uid=0, extra_params=None):
"""Configure the wifi settings."""
Expand Down
4 changes: 2 additions & 2 deletions miio/wifirepeater.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class WifiRepeater(Device):
)
def status(self) -> WifiRepeaterStatus:
"""Return the associated stations."""
return WifiRepeaterStatus(self.send("miIO.get_repeater_sta_info", []))
return WifiRepeaterStatus(self.send("miIO.get_repeater_sta_info"))

@command(
default_output=format_output(
Expand All @@ -107,7 +107,7 @@ def status(self) -> WifiRepeaterStatus:
def configuration(self) -> WifiRepeaterConfiguration:
"""Return the configuration of the accesspoint."""
return WifiRepeaterConfiguration(
self.send("miIO.get_repeater_ap_info", []))
self.send("miIO.get_repeater_ap_info"))

@command(
click.argument("wifi_roaming", type=bool),
Expand Down