Skip to content

Commit

Permalink
Configurable app key/app id
Browse files Browse the repository at this point in the history
  • Loading branch information
nbogojevic committed Dec 22, 2021
1 parent 25fc93c commit 0fd854d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions custom_components/midea_dehumidifier_lan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
ATTR_IDENTIFIERS,
ATTR_MANUFACTURER,
ATTR_MODEL,
ATTR_NAME,
ATTR_SW_VERSION,
CONF_DEVICES,
CONF_IP_ADDRESS,
CONF_NAME,
Expand All @@ -24,10 +29,10 @@
)

from midea_beautiful_dehumidifier import appliance_state, connect_to_cloud
from midea_beautiful_dehumidifier.appliance import DehumidifierAppliance
from midea_beautiful_dehumidifier.lan import LanDevice
from midea_beautiful_dehumidifier.midea import DEFAULT_APPKEY

from .const import CONF_TOKEN_KEY, DOMAIN, PLATFORMS
from .const import CONF_APPID, CONF_APPKEY, CONF_TOKEN_KEY, DOMAIN, PLATFORMS

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -78,7 +83,8 @@ async def start(self, hass: HomeAssistant, data):
connect_to_cloud,
data[CONF_USERNAME],
data[CONF_PASSWORD],
DEFAULT_APPKEY,
data[CONF_APPKEY],
data[CONF_APPID],
)
appliance = await hass.async_add_executor_job(
appliance_state,
Expand Down Expand Up @@ -120,6 +126,9 @@ async def _async_appliance_refresh(self):
"""Called to refresh appliance state"""
await self.hass.async_add_executor_job(self.appliance.refresh)

def is_dehumidifier(self) -> bool:
return DehumidifierAppliance.supported(self.appliance.type)


class ApplianceEntity(CoordinatorEntity):
"""Represents an appliance that gets data from a coordinator"""
Expand Down Expand Up @@ -171,9 +180,9 @@ def available(self) -> bool:
@property
def device_info(self):
return {
"identifiers": {(DOMAIN, self.appliance.sn)},
"name": self.appliance.name,
"manufacturer": "Midea",
"model": str(self.appliance.model),
"sw_version": self.appliance.firmware_version,
ATTR_IDENTIFIERS: {(DOMAIN, self.appliance.sn)},
ATTR_NAME: self.appliance.name,
ATTR_MANUFACTURER: "Midea",
ATTR_MODEL: str(self.appliance.model),
ATTR_SW_VERSION: self.appliance.firmware_version,
}

0 comments on commit 0fd854d

Please sign in to comment.