Skip to content

Commit

Permalink
Wrap up
Browse files Browse the repository at this point in the history
  • Loading branch information
ha0y committed Aug 22, 2021
1 parent 66caedd commit bb131a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions custom_components/xiaomi_miot_raw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ async def async_generic_setup_platform(
if 'access' in v and 'value_range' in v:
if v['access'] >> 1 & 0b01:
continue
if k in paramsnew and HAVE_SELECT:
if isinstance(paramsnew[k], dict):
if 'access' in v and 'value_list' in v:
if v['access'] >> 1 & 0b01:
continue
sensor_devices.append(sub_class_dict['_sub_sensor'](parent_device, mappingnew, paramsnew, other_mi_type[0],{'sensor_property': k}))

# device = MiotSubSensor(parent_device, "switch_switch_status")
Expand Down
11 changes: 7 additions & 4 deletions custom_components/xiaomi_miot_raw/basic_dev_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from .deps.xiaomi_cloud_new import MiCloud
from .deps.miot_coordinator import MiotCloudCoordinator
from asyncio.exceptions import CancelledError
from . import (HAVE_NUMBER, HAVE_SELECT)


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -523,21 +524,23 @@ async def create_sub_entities(self):
此处设置好添加条件后,到sensor处排除掉这些实体。"""
if not self._ctrl_params_new:
return
from .number import MiotNumberInput
from .select import MiotPropertySelector
if HAVE_NUMBER:
from .number import MiotNumberInput
if HAVE_SELECT:
from .select import MiotPropertySelector
num_to_add = []
sel_to_add = []
for k,v in self._ctrl_params_new.items():
if not isinstance(v, dict):
continue
if 'access' in v and 'value_range' in v:
if 'access' in v and 'value_range' in v and HAVE_NUMBER:
if v['access'] >> 1 & 0b01:
num_to_add.append(MiotNumberInput(
self,
full_did=k,
value_range=v['value_range']
))
elif 'access' in v and 'value_list' in v:
elif 'access' in v and 'value_list' in v and HAVE_SELECT:
if v['access'] >> 1 & 0b01:
sel_to_add.append(MiotPropertySelector(
self,
Expand Down

0 comments on commit bb131a8

Please sign in to comment.