v0.7.9
v0.7.9 更新
修复
OptionsFlow 配置向导 500 错误的真正根因 —— v0.7.7 的 try/except 思路是错的。
原因
v0.7.7 的代码:
def __init__(self, config_entry):
try:
super().__init__(config_entry)
except TypeError:
self.config_entry = config_entry实际运行时两条路都走不通(traceback 已确认):
super().__init__(config_entry)→object.__init__()不接受参数 →TypeError- except 分支
self.config_entry = ...→config_entry是只读 property →AttributeError
修复方案
不碰 config_entry 这个名字,用私有属性 self._entry 保存:
def __init__(self, config_entry):
self._entry = config_entry
async def async_step_init(self, user_input=None):
current = {**(self._entry.data or {}), **(self._entry.options or {})}无论新旧版本 HA 都能正常工作。