Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions miio/gateway/devices/subdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(
if model_info is None:
model_info = {}
self._model_info = model_info
self._battery_powered = model_info.get("battery", True)
Comment thread
starkillerOG marked this conversation as resolved.
Outdated
self._battery = None
self._voltage = None
self._fw_ver = dev_info.fw_ver
Expand Down Expand Up @@ -208,6 +209,9 @@ def unpair(self):
@command()
def get_battery(self):
"""Update the battery level, if available."""
if not self._battery_powered:
Comment thread
syssi marked this conversation as resolved.
return self._battery
Comment thread
starkillerOG marked this conversation as resolved.
Outdated

if self._gw.model not in [GATEWAY_MODEL_EU, GATEWAY_MODEL_ZIG3]:
self._battery = self.send("get_battery").pop()
else:
Expand All @@ -220,6 +224,9 @@ def get_battery(self):
@command()
def get_voltage(self):
"""Update the battery voltage, if available."""
if not self._battery_powered:
return self._voltage
Comment thread
starkillerOG marked this conversation as resolved.
Outdated

if self._gw.model in [GATEWAY_MODEL_EU, GATEWAY_MODEL_ZIG3]:
self._voltage = self.get_property("voltage").pop() / 1000
else:
Expand Down
21 changes: 21 additions & 0 deletions miio/gateway/devices/subdevices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
name: Smart bulb E27
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -152,6 +153,7 @@
name: Ikea smart bulb E27 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -177,6 +179,7 @@
name: Ikea smart bulb E27 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -202,6 +205,7 @@
name: Ikea smart bulb E12 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -227,6 +231,7 @@
name: Ikea smart bulb GU10 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -252,6 +257,7 @@
name: Ikea smart bulb E27 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -277,6 +283,7 @@
name: Ikea smart bulb GU10 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand All @@ -302,6 +309,7 @@
name: Ikea smart bulb E12 white
type: LightBulb
class: LightBulb
battery: false
properties:
- property: power_status # 'on' / 'off'
name: status
Expand Down Expand Up @@ -474,6 +482,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -489,6 +498,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -501,6 +511,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -516,6 +527,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -534,6 +546,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -549,6 +562,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -567,6 +581,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -588,6 +603,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -610,6 +626,7 @@
class: Switch
getter: get_prop_plug
setter: toggle_plug
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -626,6 +643,7 @@
class: Switch
getter: get_prop_plug
setter: toggle_plug
battery: false
properties:
- property: neutral_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -641,6 +659,7 @@
type: Switch
class: Switch
setter: toggle_plug
battery: false
properties:
- property: channel_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -653,6 +672,7 @@
type: Switch
class: Switch
setter: toggle_plug
battery: false
properties:
- property: channel_0 # 'on' / 'off'
name: status_ch0
Expand All @@ -668,6 +688,7 @@
type: Switch
class: Switch
setter: toggle_ctrl_neutral
battery: false
properties:
- property: channel_0 # 'on' / 'off'
name: status_ch0
Expand Down