mirror of
https://github.com/sususweet/midea-meiju-codec.git
synced 2026-02-27 14:16:35 +00:00
- Updated device mapping configuration to support explicit device range specification
- Changed from simple [min_kelvin, max_kelvin] format to structured format:
{"kelvin_range": [min_kelvin, max_kelvin], "device_range": [min_device, max_device]}
- This allows devices with non-standard (non-1-100) color temp ranges to be properly supported
- Improved color temperature conversion logic in light entity:
- Added support for device-specific range mapping instead of hardcoded 1-100 range
- Enhanced configuration detection to handle both direct and nested formats
- Updated kelvin-to-device and device-to-kelvin conversion to use dynamic ranges
146 lines
5.6 KiB
Python
146 lines
5.6 KiB
Python
from homeassistant.components.fan import DIRECTION_FORWARD, DIRECTION_REVERSE
|
|
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_WHOLE
|
|
|
|
DEVICE_MAPPING = {
|
|
"default": {
|
|
"rationale": ["off", "on"],
|
|
"queries": [{}],
|
|
"centralized": [],
|
|
"entities": {
|
|
Platform.LIGHT: {
|
|
"light": {
|
|
"power": "power",
|
|
"brightness": {"brightness": [1, 100]},
|
|
"color_temp": {
|
|
"color_temperature": {
|
|
"kelvin_range": [3000, 5700],
|
|
"device_range": [0, 100]
|
|
}
|
|
},
|
|
"preset_modes": {
|
|
"night": {"scene_light": "night"},
|
|
"read": {"scene_light": "read"},
|
|
"mild": {"scene_light": "mild"},
|
|
"life": {"scene_light": "life"},
|
|
"film": {"scene_light": "film"},
|
|
"manual": {"scene_light": "manual"},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"M0200015": {
|
|
"rationale": ["off", "on"],
|
|
"queries": [{}],
|
|
"centralized": [],
|
|
"entities": {
|
|
Platform.LIGHT: {
|
|
"light": {
|
|
"power": "led_power",
|
|
"brightness": {"brightness": [1, 100]},
|
|
"color_temp": {
|
|
"color_temperature": {
|
|
"kelvin_range": [2700, 6500],
|
|
"device_range": [0, 100]
|
|
}
|
|
},
|
|
"preset_modes": {
|
|
"work": {"led_scene_light": "work"},
|
|
"eating": {"led_scene_light": "eating"},
|
|
"film": {"led_scene_light": "film"},
|
|
"night": {"led_scene_light": "night"},
|
|
"ledmanual": {"led_scene_light": "ledmanual"},
|
|
}
|
|
}
|
|
},
|
|
Platform.FAN: {
|
|
"fan": {
|
|
"power": "fan_power",
|
|
"speeds": list({"fan_speed": value + 1} for value in range(0, 6)),
|
|
"preset_modes": {
|
|
"breathing_wind": {"fan_scene": "breathing_wind"},
|
|
"const_temperature": {"fan_scene": "const_temperature"},
|
|
"fanmanual": {"fan_scene": "fanmanual"},
|
|
"baby_wind": {"fan_scene": "baby_wind"},
|
|
"sleep_wind": {"fan_scene": "sleep_wind"},
|
|
"forest_wind": {"fan_scene": "forest_wind"}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"79010863": {
|
|
"rationale": ["off", "on"],
|
|
"queries": [{}],
|
|
"centralized": [],
|
|
"calculate": {
|
|
"get": [
|
|
{
|
|
"lvalue": "[device_fan_speed]",
|
|
"rvalue": "int((int([fan_speed])) / 20) + 1"
|
|
},
|
|
],
|
|
"set": [
|
|
{
|
|
"lvalue": "[fan_speed]",
|
|
"rvalue": "min(int((int([device_fan_speed]) - 1) * 20 + 1), 100)"
|
|
},
|
|
]
|
|
},
|
|
"entities": {
|
|
Platform.LIGHT: {
|
|
"light": {
|
|
"power": "led_power",
|
|
"brightness": {"brightness": [1, 100]},
|
|
"color_temp": {
|
|
"color_temperature": {
|
|
"kelvin_range": [2700, 6500],
|
|
"device_range": [0, 100]
|
|
}
|
|
},
|
|
"preset_modes": {
|
|
"work": {"led_scene_light": "work"},
|
|
"eating": {"led_scene_light": "eating"},
|
|
"film": {"led_scene_light": "film"},
|
|
"night": {"led_scene_light": "night"},
|
|
"ledmanual": {"led_scene_light": "ledmanual"},
|
|
}
|
|
}
|
|
},
|
|
Platform.FAN: {
|
|
"fan": {
|
|
"power": "fan_power",
|
|
"speeds": list({"device_fan_speed": value + 1} for value in range(0, 6)),
|
|
"preset_modes": {
|
|
"breathing_wind": {"fan_scene": "breathing_wind"},
|
|
"const_temperature": {"fan_scene": "const_temperature"},
|
|
"fanmanual": {"fan_scene": "fanmanual"},
|
|
"baby_wind": {"fan_scene": "baby_wind"},
|
|
"sleep_wind": {"fan_scene": "sleep_wind"},
|
|
"forest_wind": {"fan_scene": "forest_wind"}
|
|
},
|
|
"directions": {
|
|
DIRECTION_FORWARD: {"arround_dir": "1"},
|
|
DIRECTION_REVERSE: {"arround_dir": "0"},
|
|
}
|
|
}
|
|
},
|
|
Platform.CLIMATE: {
|
|
"thermostat": {
|
|
"power": "fan_power",
|
|
"hvac_modes": {
|
|
"off": {"fan_scene": "fanmanual"},
|
|
"auto": {"fan_scene": "const_temperature"},
|
|
},
|
|
"target_temperature": "const_temperature_value",
|
|
"current_temperature": "indoor_temperature",
|
|
"min_temp": 20,
|
|
"max_temp": 35,
|
|
"temperature_unit": UnitOfTemperature.CELSIUS,
|
|
"precision": PRECISION_WHOLE,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|