Skip to content

Commit

Permalink
fix use cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Sep 24, 2024
1 parent 4db1fbf commit c45f6d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions custom_components/xiaomi_miot/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.helpers.device_registry import format_mac
import homeassistant.helpers.config_validation as cv

from .const import DOMAIN, DEVICE_CUSTOMIZES, DEFAULT_NAME, CONF_CONN_MODE, DEFAULT_CONN_MODE
from .const import DOMAIN, DEVICE_CUSTOMIZES, MIOT_LOCAL_MODELS, DEFAULT_NAME, CONF_CONN_MODE, DEFAULT_CONN_MODE
from .hass_entry import HassEntry
from .converters import BaseConv, MiotPropConv, MiotPropValueConv, MiotActionConv
from .miot_spec import MiotSpec, MiotResults
Expand Down Expand Up @@ -128,7 +128,8 @@ def __init__(self, info: DeviceInfo, entry: HassEntry):
self.listeners: list[Callable] = []
self.converters: list[BaseConv] = []

self.local = MiotDevice.from_device(self)
if not self.cloud_only:
self.local = MiotDevice.from_device(self)

@cached_property
def did(self):
Expand Down Expand Up @@ -411,7 +412,8 @@ async def update_miot_status(
self.miot_results = MiotResults(results)

if use_local is None:
use_local = self.local or self.miio2miot
if self.local:
use_local = self.miio2miot or self.model in MIOT_LOCAL_MODELS
if self.cloud_only or use_cloud:
use_local = False
if use_cloud is None:
Expand Down
3 changes: 1 addition & 2 deletions custom_components/xiaomi_miot/core/hass_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ async def new_device(self, device_info: dict, cloud: Optional[MiotCloud] = None)
device = Device(info, self)
device.cloud = cloud
spec = await device.get_spec()
if spec and not device.cloud_only:
if spec and device.local and not device.cloud_only:
device.miio2miot = Miio2MiotHelper.from_model(self.hass, device.model, spec)
await device.update_miot_status() # TODO
self.devices[info.unique_id] = device
return device

Expand Down

0 comments on commit c45f6d7

Please sign in to comment.