mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2025-10-15 10:48:26 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
273d4e41bf | ||
![]() |
e9a6c65787 | ||
![]() |
beaf837e3b | ||
![]() |
a7efce2d26 | ||
![]() |
9ff67da49b |
@@ -131,16 +131,16 @@ async def async_setup(hass: HomeAssistant, config: ConfigType):
|
|||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
cjson = os.getcwd() + "/cjson.lua"
|
cjson = os.getcwd() + "/cjson.lua"
|
||||||
bit = os.getcwd() + "/bit.lua"
|
bit = os.getcwd() + "/bit.lua"
|
||||||
if not os.path.exists(cjson):
|
# if not os.path.exists(cjson):
|
||||||
from .const import CJSON_LUA
|
from .const import CJSON_LUA
|
||||||
cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8")
|
cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8")
|
||||||
with open(cjson, "wt") as fp:
|
with open(cjson, "wt") as fp:
|
||||||
fp.write(cjson_lua)
|
fp.write(cjson_lua)
|
||||||
if not os.path.exists(bit):
|
# if not os.path.exists(bit):
|
||||||
from .const import BIT_LUA
|
from .const import BIT_LUA
|
||||||
bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8")
|
bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8")
|
||||||
with open(bit, "wt") as fp:
|
with open(bit, "wt") as fp:
|
||||||
fp.write(bit_lua)
|
fp.write(bit_lua)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -140,8 +140,13 @@ class MiedaDevice(threading.Thread):
|
|||||||
for attr in self._centralized:
|
for attr in self._centralized:
|
||||||
new_status[attr] = self._attributes.get(attr)
|
new_status[attr] = self._attributes.get(attr)
|
||||||
new_status[attribute] = value
|
new_status[attribute] = value
|
||||||
if set_cmd := self._lua_runtime.build_control(new_status):
|
try:
|
||||||
await self._build_send(set_cmd)
|
if set_cmd := self._lua_runtime.build_control(new_status):
|
||||||
|
await self._build_send(set_cmd)
|
||||||
|
except Exception as e:
|
||||||
|
cloud = self._cloud
|
||||||
|
if cloud and hasattr(cloud, "send_device_control"):
|
||||||
|
await cloud.send_device_control(self._device_id, control=new_status, status=self._attributes)
|
||||||
|
|
||||||
async def set_attributes(self, attributes):
|
async def set_attributes(self, attributes):
|
||||||
new_status = {}
|
new_status = {}
|
||||||
@@ -153,8 +158,13 @@ class MiedaDevice(threading.Thread):
|
|||||||
has_new = True
|
has_new = True
|
||||||
new_status[attribute] = value
|
new_status[attribute] = value
|
||||||
if has_new:
|
if has_new:
|
||||||
if set_cmd := self._lua_runtime.build_control(new_status):
|
try:
|
||||||
await self._build_send(set_cmd)
|
if set_cmd := self._lua_runtime.build_control(new_status):
|
||||||
|
await self._build_send(set_cmd)
|
||||||
|
except Exception as e:
|
||||||
|
cloud = self._cloud
|
||||||
|
if cloud and hasattr(cloud, "send_device_control"):
|
||||||
|
await cloud.send_device_control(self._device_id, control=new_status, status=self._attributes)
|
||||||
|
|
||||||
def set_ip_address(self, ip_address):
|
def set_ip_address(self, ip_address):
|
||||||
MideaLogger.debug(f"Update IP address to {ip_address}")
|
MideaLogger.debug(f"Update IP address to {ip_address}")
|
||||||
|
@@ -6,7 +6,7 @@ from .logger import MideaLogger
|
|||||||
|
|
||||||
class LuaRuntime:
|
class LuaRuntime:
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
self._runtimes = lupa.LuaRuntime()
|
self._runtimes = lupa.lua51.LuaRuntime()
|
||||||
string = f'dofile("{file}")'
|
string = f'dofile("{file}")'
|
||||||
self._runtimes.execute(string)
|
self._runtimes.execute(string)
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
|
@@ -6,7 +6,7 @@ from homeassistant.components.switch import SwitchDeviceClass
|
|||||||
DEVICE_MAPPING = {
|
DEVICE_MAPPING = {
|
||||||
"default": {
|
"default": {
|
||||||
"rationale": ["off", "on"],
|
"rationale": ["off", "on"],
|
||||||
"queries": [{}],
|
"queries": [{}, {"query_type":"run_status"}],
|
||||||
"centralized": [
|
"centralized": [
|
||||||
"power", "temperature", "small_temperature", "mode", "eco",
|
"power", "temperature", "small_temperature", "mode", "eco",
|
||||||
"comfort_power_save", "strong_wind",
|
"comfort_power_save", "strong_wind",
|
||||||
@@ -77,11 +77,11 @@ DEVICE_MAPPING = {
|
|||||||
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"outdoor_temperature": {
|
"indoor_humidity": {
|
||||||
"device_class": SensorDeviceClass.TEMPERATURE,
|
"device_class": SensorDeviceClass.HUMIDITY,
|
||||||
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
"unit_of_measurement": "%",
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -155,8 +155,12 @@ DEVICE_MAPPING = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Platform.SENSOR: {
|
Platform.SENSOR: {
|
||||||
|
"indoor_temperature": {
|
||||||
|
"device_class": SensorDeviceClass.TEMPERATURE,
|
||||||
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
||||||
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
|
},
|
||||||
"outdoor_temperature": {
|
"outdoor_temperature": {
|
||||||
"name": "室外机温度",
|
|
||||||
"device_class": SensorDeviceClass.TEMPERATURE,
|
"device_class": SensorDeviceClass.TEMPERATURE,
|
||||||
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
"unit_of_measurement": UnitOfTemperature.CELSIUS,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
|
@@ -127,19 +127,19 @@ DEVICE_MAPPING = {
|
|||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"people_number": {
|
"people_number": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.DATA_RATE,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"steam_quantity": {
|
"steam_quantity": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"totalstep": {
|
"totalstep": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"stepnum": {
|
"stepnum": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"hour_set": {
|
"hour_set": {
|
||||||
@@ -158,23 +158,23 @@ DEVICE_MAPPING = {
|
|||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"ota": {
|
"ota": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"error_code": {
|
"error_code": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"cbs_version": {
|
"cbs_version": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"cloudmenuid": {
|
"cloudmenuid": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,48 +50,15 @@ DEVICE_MAPPING = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Platform.SWITCH: {
|
Platform.SWITCH: {
|
||||||
"music": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"ti_protect": {
|
"ti_protect": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"fast_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"ali_manager": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"heat": {
|
"heat": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"ele_exception": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"communication_error": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"eplus": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"summer": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"winter": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"efficient": {
|
"efficient": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"night": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"bath_person": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"cloud": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"bath": {
|
"bath": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
@@ -101,87 +68,12 @@ DEVICE_MAPPING = {
|
|||||||
"whole_heat": {
|
"whole_heat": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"sterilization": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"frequency_hot": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"scene": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"big_water": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"negative_ions": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"screen_off": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"t_hot": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"baby_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"dad_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"mom_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"wash_with_temp": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"single_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"people_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"one_egg": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"two_egg": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"always_fell": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"smart_sterilize": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"sound_dad": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"door_status": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"limit_error": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"sensor_error": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"auto_off": {
|
"auto_off": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"clean": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"cloud_appoint": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"protect": {
|
"protect": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"midea_manager": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"sleep": {
|
"sleep": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
@@ -191,9 +83,6 @@ DEVICE_MAPPING = {
|
|||||||
"shower": {
|
"shower": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"scroll_hot": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"fast_hot_power": {
|
"fast_hot_power": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
@@ -206,54 +95,12 @@ DEVICE_MAPPING = {
|
|||||||
"water_flow": {
|
"water_flow": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"appoint_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"now_wash": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"get_time": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"get_temp": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"warm_power": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"sterilize_high_temp": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"bottom_heat": {
|
"bottom_heat": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"top_heat": {
|
"top_heat": {
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
"device_class": SwitchDeviceClass.SWITCH,
|
||||||
},
|
},
|
||||||
"show_h": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"uv_sterilize": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"need_discharge": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"elec_warning": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"water_cyclic": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"tech_water": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"protect_show": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
},
|
|
||||||
"appoint_power": {
|
|
||||||
"device_class": SwitchDeviceClass.SWITCH,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Platform.SELECT: {
|
Platform.SELECT: {
|
||||||
"mode": {
|
"mode": {
|
||||||
@@ -365,22 +212,11 @@ DEVICE_MAPPING = {
|
|||||||
"unit_of_measurement": UnitOfTime.MINUTES,
|
"unit_of_measurement": UnitOfTime.MINUTES,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"version": {
|
|
||||||
"device_class": SensorDeviceClass.ENUM
|
|
||||||
},
|
|
||||||
"tds_value": {
|
"tds_value": {
|
||||||
"device_class": SensorDeviceClass.WATER,
|
"device_class": SensorDeviceClass.WATER,
|
||||||
"unit_of_measurement": "ppm",
|
"unit_of_measurement": "ppm",
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"scene_id": {
|
|
||||||
"device_class": SensorDeviceClass.ENUM
|
|
||||||
},
|
|
||||||
"volume": {
|
|
||||||
"device_class": SensorDeviceClass.SOUND_PRESSURE,
|
|
||||||
"unit_of_measurement": "%",
|
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
|
||||||
},
|
|
||||||
"heat_water_level": {
|
"heat_water_level": {
|
||||||
"device_class": SensorDeviceClass.WATER,
|
"device_class": SensorDeviceClass.WATER,
|
||||||
"unit_of_measurement": "%",
|
"unit_of_measurement": "%",
|
||||||
|
@@ -107,7 +107,7 @@ DEVICE_MAPPING = {
|
|||||||
},
|
},
|
||||||
Platform.SENSOR: {
|
Platform.SENSOR: {
|
||||||
"real_gear": {
|
"real_gear": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"dust_life_time": {
|
"dust_life_time": {
|
||||||
@@ -130,7 +130,7 @@ DEVICE_MAPPING = {
|
|||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"error_code": {
|
"error_code": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"temperature_feedback": {
|
"temperature_feedback": {
|
||||||
@@ -139,7 +139,7 @@ DEVICE_MAPPING = {
|
|||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"water_feedback": {
|
"water_feedback": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"timer_off_hour": {
|
"timer_off_hour": {
|
||||||
@@ -163,7 +163,7 @@ DEVICE_MAPPING = {
|
|||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"pm25": {
|
"pm25": {
|
||||||
@@ -172,26 +172,26 @@ DEVICE_MAPPING = {
|
|||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"ud_swing_angle": {
|
"ud_swing_angle": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"lr_diy_down_percent": {
|
"lr_diy_down_percent": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"unit_of_measurement": PERCENTAGE,
|
"unit_of_measurement": PERCENTAGE,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"lr_diy_up_percent": {
|
"lr_diy_up_percent": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"unit_of_measurement": PERCENTAGE,
|
"unit_of_measurement": PERCENTAGE,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"ud_diy_down_percent": {
|
"ud_diy_down_percent": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"unit_of_measurement": PERCENTAGE,
|
"unit_of_measurement": PERCENTAGE,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
},
|
},
|
||||||
"ud_diy_up_percent": {
|
"ud_diy_up_percent": {
|
||||||
"device_class": SensorDeviceClass.NONE,
|
"device_class": SensorDeviceClass.ENUM,
|
||||||
"unit_of_measurement": PERCENTAGE,
|
"unit_of_measurement": PERCENTAGE,
|
||||||
"state_class": SensorStateClass.MEASUREMENT
|
"state_class": SensorStateClass.MEASUREMENT
|
||||||
}
|
}
|
||||||
|
@@ -7,5 +7,5 @@
|
|||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"issue_tracker": "https://github.com/sususweet/midea-meiju-codec/issues",
|
"issue_tracker": "https://github.com/sususweet/midea-meiju-codec/issues",
|
||||||
"requirements": ["lupa>=2.0"],
|
"requirements": ["lupa>=2.0"],
|
||||||
"version": "v0.1.0"
|
"version": "v0.1.1"
|
||||||
}
|
}
|
@@ -5,7 +5,6 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .core.logger import MideaLogger
|
|
||||||
from .midea_entity import MideaEntity
|
from .midea_entity import MideaEntity
|
||||||
from . import load_device_config
|
from . import load_device_config
|
||||||
|
|
||||||
|
@@ -1,14 +1,23 @@
|
|||||||
from homeassistant.components.water_heater import WaterHeaterEntity, WaterHeaterEntityFeature
|
from homeassistant.components.water_heater import WaterHeaterEntity, WaterHeaterEntityFeature
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
Platform,
|
Platform,
|
||||||
ATTR_TEMPERATURE
|
ATTR_TEMPERATURE
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .midea_entity import MideaEntity
|
from .midea_entity import MideaEntity
|
||||||
from . import load_device_config
|
from . import load_device_config
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up water heater entities for Midea devices."""
|
||||||
account_bucket = hass.data.get(DOMAIN, {}).get("accounts", {}).get(config_entry.entry_id)
|
account_bucket = hass.data.get(DOMAIN, {}).get("accounts", {}).get(config_entry.entry_id)
|
||||||
if not account_bucket:
|
if not account_bucket:
|
||||||
async_add_entities([])
|
async_add_entities([])
|
||||||
@@ -51,30 +60,6 @@ class MideaWaterHeaterEntityEntity(MideaEntity, WaterHeaterEntity):
|
|||||||
self._manufacturer = manufacturer
|
self._manufacturer = manufacturer
|
||||||
self._rationale = rationale
|
self._rationale = rationale
|
||||||
self._config = config
|
self._config = config
|
||||||
# Legacy compatibility: register update and restore display attributes
|
|
||||||
if self._device:
|
|
||||||
self._device.register_update(self.update_state)
|
|
||||||
if (rationale_local := self._config.get("rationale")) is not None:
|
|
||||||
self._rationale = rationale_local
|
|
||||||
if self._rationale is None:
|
|
||||||
self._rationale = ["off", "on"]
|
|
||||||
self._attr_native_unit_of_measurement = self._config.get("unit_of_measurement")
|
|
||||||
self._attr_device_class = self._config.get("device_class")
|
|
||||||
self._attr_state_class = self._config.get("state_class")
|
|
||||||
self._attr_icon = self._config.get("icon")
|
|
||||||
from .const import DOMAIN as _DOMAIN
|
|
||||||
self._attr_unique_id = f"{_DOMAIN}.{self._device.device_id}_{self._entity_key}"
|
|
||||||
self._attr_device_info = {
|
|
||||||
"manufacturer": "Midea" if self._manufacturer is None else self._manufacturer,
|
|
||||||
"model": f"{self._device.model}",
|
|
||||||
"identifiers": {( _DOMAIN, self._device.device_id)},
|
|
||||||
"name": self._device.device_name
|
|
||||||
}
|
|
||||||
name = self._config.get("name")
|
|
||||||
if name is None:
|
|
||||||
name = self._entity_key.replace("_", " ").title()
|
|
||||||
self._attr_name = f"{self._device.device_name} {name}"
|
|
||||||
self.entity_id = self._attr_unique_id
|
|
||||||
self._key_power = self._config.get("power")
|
self._key_power = self._config.get("power")
|
||||||
self._key_operation_list = self._config.get("operation_list")
|
self._key_operation_list = self._config.get("operation_list")
|
||||||
self._key_min_temp = self._config.get("min_temp")
|
self._key_min_temp = self._config.get("min_temp")
|
||||||
@@ -167,9 +152,3 @@ class MideaWaterHeaterEntityEntity(MideaEntity, WaterHeaterEntity):
|
|||||||
if new_status:
|
if new_status:
|
||||||
await self.async_set_attributes(new_status)
|
await self.async_set_attributes(new_status)
|
||||||
|
|
||||||
def update_state(self, status):
|
|
||||||
try:
|
|
||||||
self.schedule_update_ha_state()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user