Skip to content

增加了HD设备支持#2

Closed
zjufrankzhang wants to merge 3 commits into
caibinqing:devfrom
zjufrankzhang:dev
Closed

增加了HD设备支持#2
zjufrankzhang wants to merge 3 commits into
caibinqing:devfrom
zjufrankzhang:dev

Conversation

@zjufrankzhang

Copy link
Copy Markdown

趁着春节放假花了好几天反解了大金的包,把HD的支持做上去了。和原来的主线代码差别太大,我从你这里拉的基础包,给你推回来。我python是三脚猫水平,代码是AI生成+自己审核并测试上来的,在合并的时候注意了尽可能减少对已有代码的扰动。目前简单用下来没有问题,不过可能需要更多人来进一步测试。

增加滤网清洁提示的信息,但没有重写do方法。只接收并处理,但没有后续动作,主要是为了在log中少一点未知消息。
增加了HD实体支持
@caibinqing

Copy link
Copy Markdown
Owner

/gemini review

@caibinqing

Copy link
Copy Markdown
Owner

@codex review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces support for HD (Heat Exchanger) devices, adding WATER_HEATER and SWITCH platforms. It includes new data access objects (HD, HDStatus), command types, and decoding logic for HD devices. The service layer has been updated to manage HD devices, including initialization, status polling, and control. New Home Assistant entities (DsWaterHeater, DsHdMuteSwitch) are implemented to expose HD functionality. The changes appear to be well-structured and integrate HD device support effectively into the existing system. The author has also added helpful comments in Chinese to explain certain parts of the code, which is a good practice for maintainability.

# 发送指令
CONTROL = 1
STATUS_CHANGED = 2
STATUS_CHANGED = 2 #对于HD设备,是开关状态改变会出现本指令

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment 对于HD设备,是开关状态改变会出现本指令 is helpful, but it would be better to place it on a separate line or use a more standard inline comment format if it's meant to be a permanent explanation. If it's a temporary note, it should be removed before merging.

Suggested change
STATUS_CHANGED = 2 #对于HD设备,是开关状态改变会出现本指令
STATUS_CHANGED = 2 # 对于HD设备,是开关状态改变会出现本指令

HD_INFO_QUERY = 12
HD_INFO_CHANGE = 13
HD_CONTROL_BASE = 14
HD_CONTROL_OTHER = 15 #这个当前只有获取夜间节能模式这一个功能

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the previous comment, consider placing this comment on a separate line for better readability and to avoid potential issues with line length limits or code formatters. If it's a temporary note, it should be removed before merging.

Suggested change
HD_CONTROL_OTHER = 15 #这个当前只有获取夜间节能模式这一个功能
HD_CONTROL_OTHER = 15 # 这个当前只有获取夜间节能模式这一个功能

preheat: int | None = None,
switch_enable: EnumControl.Switch | None = None,
temperature_set: int | None = None,
warm_cold: int | None = None, #1为制热状态

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment 1为制热状态 is helpful, but it would be better to place it on a separate line or use a more standard inline comment format if it's meant to be a permanent explanation. If it's a temporary note, it should be removed before merging.

Suggested change
warm_cold: int | None = None, #1为制热状态
warm_cold: int | None = None, # 1为制热状态

Comment on lines +641 to +644
#HDQueryInfoParam在我的DTA117C611上没有返回,注释掉了
#p = HDQueryInfoParam()
#p.device = hd
#service.send_msg(p)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These commented-out lines suggest that HDQueryInfoParam might not be fully functional or necessary. It's generally better to remove dead code or code that is not actively used, especially if it's causing issues or not returning responses. If there's a plan to re-enable this, consider adding a TODO comment with a clear explanation.

Comment on lines +1219 to +1224
#def do(self, service: Service) -> None:
# _LOGGER.debug(f"[HDStatusChangeResult] 执行HD状态查询结果: room={self._room}, unit={self._unit}")
# try:
# service.set_hd_status(self._room, self._unit, self._status)
# except Exception as e:
# _LOGGER.error(f"[HDStatusChangeResult] 设置HD状态时出错: {e}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These commented-out lines suggest that the do method for HDStatusChangeResult is intentionally disabled. If this functionality is not needed, the method should be removed entirely. If it's temporarily disabled, add a TODO comment explaining why and when it should be re-enabled.


_log(display(self._device_info.status))
self.hass.loop.call_soon_threadsafe(self.async_write_ha_state)
_log(f"[HD Entity] 状态更新完成")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _log call here is for debugging and should ideally be removed or converted to _LOGGER.debug calls before merging into production code. Excessive logging can impact performance and disk space.

Comment on lines +175 to +176
_log(f"[HD Entity] 模式未知: {self._device_info.status.switch}")
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _log call here is for debugging and should ideally be removed or converted to _LOGGER.debug calls before merging into production code. Excessive logging can impact performance and disk space.

async def async_set_temperature(self, **kwargs) -> None:
"""Set new target temperature."""
temperature = kwargs.get(ATTR_TEMPERATURE)
if temperature is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _log call here is for debugging and should ideally be removed or converted to _LOGGER.debug calls before merging into production code. Excessive logging can impact performance and disk space.


async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set new operation mode."""
_log(f"[HD Entity] 设置操作模式: {operation_mode}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _log call here is for debugging and should ideally be removed or converted to _LOGGER.debug calls before merging into production code. Excessive logging can impact performance and disk space.

# 同时更新本地状态以提供即时UI反馈
self._device_info.status.switch = EnumControl.Switch.OFF
else:
_log(f"[HD Entity] 不支持的操作模式: {operation_mode}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The _log call here is for debugging and should ideally be removed or converted to _LOGGER.debug calls before merging into production code. Excessive logging can impact performance and disk space.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b552283ca0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread custom_components/ds_air/ds_air_service/service.py Outdated
Comment on lines +1219 to +1221
#def do(self, service: Service) -> None:
# _LOGGER.debug(f"[HDStatusChangeResult] 执行HD状态查询结果: room={self._room}, unit={self._unit}")
# try:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply HD STATUS_CHANGED packets to entity state

result_factory routes HD STATUS_CHANGED packets to HDStatusChangeResult (decoder.py:149-150), and load_bytes parses the switch field, but the do(...) handler is commented out here. As a result, when gateways emit this packet type (notably for switch changes), the update is decoded then dropped, so Home Assistant state can remain stale until a later poll/other message arrives.

Useful? React with 👍 / 👎.

@caibinqing

Copy link
Copy Markdown
Owner

我有点犹豫要不要合哈,因为我也没有HD设备可以测试,我觉得有需要的直接去拉你的仓库用也可以,这个PR可以留在这里给别人指路。

我这个仓库只对原版做了一些代码重构,核心逻辑是没有动的,所以协议这块其实我也没细看过。

@caibinqing

Copy link
Copy Markdown
Owner

另外你看看上面这条评论 #2 (comment)

这里的逻辑似乎和原本有些区别,之前是等4个都初始化完成,现在你用了 room and (.. or .. or ..) 的形式,而且还没包含你新增的 hd_initialized

@zjufrankzhang

Copy link
Copy Markdown
Author

另外你看看上面这条评论 #2 (comment)

这里的逻辑似乎和原本有些区别,之前是等4个都初始化完成,现在你用了 room and (.. or .. or ..) 的形式,而且还没包含你新增的 hd_initialized

感谢回复,看了下好像确实逻辑被改的有点问题。这个初始化因为流程很快,所以我本地倒没出问题。我再去改一下逻辑

修复初始化的逻辑问题
@caibinqing

Copy link
Copy Markdown
Owner

上游已恢复活跃,这边先关闭了

@caibinqing caibinqing closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants