rxwen / homeassistant-terncy-component

Terncy custom component for homeassistant
https://www.terncy.com
72 stars 11 forks source link

重启后无法正常控制,删除组件重新加载无法发现网关里的设备 #38

Closed qweasdzxc54188 closed 1 year ago

qweasdzxc54188 commented 1 year ago

ha版本:2023.5.2 问题:小燕网关里面有一个调光模块。第一次添加小燕组件可以正常控制,但是重启后灯光可以读取状态但是无法控制,日志为Unable to find referenced entities light.1 or it is/they are currently not available。然后删除组件,在重新添加组件,小燕网关正常添加,但是调光模块无法发现。日志为: 2023-06-15 17:10:07.027 INFO (MainThread) [custom_components.terncy.config_flow] construct Terncy obj for 1c8259900e36 192.168.2.248 2023-06-15 17:10:10.804 WARNING (MainThread) [custom_components.terncy.config_flow] request a new token form terncy box-1c-82-59-90-0e-36 2023-06-15 17:10:11.414 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityAvailable'} 2023-06-15 17:10:11.415 INFO (MainThread) [custom_components.terncy] [box-1c-82-59-90-0e-36] token-00000017 is available 2023-06-15 17:10:11.418 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityAvailable'} 2023-06-15 17:10:11.418 INFO (MainThread) [custom_components.terncy] [box-1c-82-59-90-0e-36] token-00000017 is available 2023-06-15 17:10:11.421 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityAvailable'} 2023-06-15 17:10:11.421 INFO (MainThread) [custom_components.terncy] [box-1c-82-59-90-0e-36] token-00000017 is available 2023-06-15 17:10:11.425 INFO (MainThread) [custom_components.terncy] update or create entity {'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'} 2023-06-15 17:10:11.426 INFO (MainThread) [custom_components.terncy] update or create entity {'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'} 2023-06-15 17:10:11.427 INFO (MainThread) [custom_components.terncy] update or create entity {'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'} 2023-06-15 17:10:17.120 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityUpdated'} 2023-06-15 17:10:17.120 INFO (MainThread) [custom_components.terncy] unsupported event type entityUpdated 2023-06-15 17:10:17.123 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityUpdated'} 2023-06-15 17:10:17.123 INFO (MainThread) [custom_components.terncy] unsupported event type entityUpdated 2023-06-15 17:10:17.125 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityUpdated'} 2023-06-15 17:10:17.126 INFO (MainThread) [custom_components.terncy] unsupported event type entityUpdated 2023-06-15 17:10:21.256 WARNING (MainThread) [custom_components.terncy.config_flow] token valid, create entry for box-1c-82-59-90-0e-36 2023-06-15 17:10:21.262 INFO (MainThread) [custom_components.terncy] terncy domain async_setup_entry box-1c-82-59-90-0e-36 2023-06-15 17:10:21.263 INFO (MainThread) [custom_components.terncy] start connection to box-1c-82-59-90-0e-36 192.168.2.248 2023-06-15 17:10:21.277 INFO (MainThread) [homeassistant.components.light] Setting up light.terncy 2023-06-15 17:10:21.281 INFO (MainThread) [homeassistant.components.cover] Setting up cover.terncy 2023-06-15 17:10:21.286 INFO (MainThread) [homeassistant.components.switch] Setting up switch.terncy 2023-06-15 17:10:21.291 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.terncy 2023-06-15 17:10:21.297 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.terncy 2023-06-15 17:10:21.305 INFO (MainThread) [terncy.terncy] Terncy v0.3.5 starting connection to: 2023-06-15 17:10:21.305 INFO (MainThread) [terncy.terncy] box-1c-82-59-90-0e-36 192.168.2.248:443 2023-06-15 17:10:21.311 INFO (MainThread) [custom_components.terncy.light] setup terncy light platform 2023-06-15 17:10:21.313 INFO (MainThread) [custom_components.terncy.cover] setup terncy curtain platform 2023-06-15 17:10:21.315 INFO (MainThread) [custom_components.terncy.switch] setup terncy smart plug platform 2023-06-15 17:10:21.317 INFO (MainThread) [custom_components.terncy.binary_sensor] setup terncy curtain platform 2023-06-15 17:10:21.319 INFO (MainThread) [custom_components.terncy.sensor] setup terncy curtain platform 2023-06-15 17:10:21.854 INFO (MainThread) [terncy.terncy] connected to box-1c-82-59-90-0e-36 2023-06-15 17:10:21.855 INFO (MainThread) [custom_components.terncy] got connected event box-1c-82-59-90-0e-36 2023-06-15 17:10:21.859 INFO (MainThread) [custom_components.terncy] refresh devices now 2023-06-15 17:10:21.896 INFO (MainThread) [custom_components.terncy] update or create entity {'hwVersion': 2, 'id': '8cf681fffe4fa7ac-00', 'model': 'TERNCY-ST01-CV', 'online': True, 'ota': -1, 'services': [{'attributes': [{'attr': 'hue', 'value': 246}, {'attr': 'saturation', 'value': 254}, {'attr': 'colorTemperature', 'value': 0}, {'attr': 'brightness', 'value': 0}, {'attr': 'on', 'value': 0}], 'id': '8cf681fffe4fa7ac-01', 'name': '1', 'profile': 27}], 'type': 'device', 'version': 50} 2023-06-15 17:10:21.897 INFO (MainThread) [custom_components.terncy] Updating service {'attributes': [{'attr': 'hue', 'value': 246}, {'attr': 'saturation', 'value': 254}, {'attr': 'colorTemperature', 'value': 0}, {'attr': 'brightness', 'value': 0}, {'attr': 'on', 'value': 0}], 'id': '8cf681fffe4fa7ac-01', 'name': '1', 'profile': 27}, available=True 2023-06-15 17:10:21.897 INFO (MainThread) [custom_components.terncy] need to add dev 1 27 8cf681fffe4fa7ac-01 to platform 2023-06-15 17:10:21.897 INFO (MainThread) [custom_components.terncy] add device 1 of light to light 2023-06-15 17:10:21.907 ERROR (MainThread) [homeassistant.components.light] Platform terncy does not generate unique IDs. ID 8cf681fffe4fa7ac-01 already exists - ignoring light.1 2023-06-15 17:10:21.911 INFO (MainThread) [custom_components.terncy.light] update state event to [{'attr': 'hue', 'value': 246}, {'attr': 'saturation', 'value': 254}, {'attr': 'colorTemperature', 'value': 0}, {'attr': 'brightness', 'value': 0}, {'attr': 'on', 'value': 0}] 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] update or create entity {'hwVersion': 1, 'id': '8cf681fffeba93b1-00', 'model': 'SM0202', 'online': True, 'ota': -1, 'services': [{'attributes': [{'attr': 'battery', 'value': 200}, {'attr': 'iasZoneStatus', 'value': 0}], 'id': '8cf681fffeba93b1-01', 'name': '', 'profile': 21}], 'type': 'device', 'version': 71} 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] Updating service {'attributes': [{'attr': 'battery', 'value': 200}, {'attr': 'iasZoneStatus', 'value': 0}], 'id': '8cf681fffeba93b1-01', 'name': '', 'profile': 21}, available=True 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] unsupported profile 21 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] update or create entity {'hwVersion': 1, 'id': 'box-1c-82-59-90-0e-36', 'model': 'TERNCY-GW02', 'online': True, 'ota': 30187, 'services': [{'attributes': [{'attr': 'volume', 'value': 57}, {'attr': 'playState', 'value': 0}, {'attr': 'mute', 'value': 0}], 'id': 'box-1c-82-59-90-0e-36-01', 'name': '1c8259900e36', 'profile': 16}], 'type': 'device', 'version': 30098} 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] Updating service {'attributes': [{'attr': 'volume', 'value': 57}, {'attr': 'playState', 'value': 0}, {'attr': 'mute', 'value': 0}], 'id': 'box-1c-82-59-90-0e-36-01', 'name': '1c8259900e36', 'profile': 16}, available=True 2023-06-15 17:10:21.913 INFO (MainThread) [custom_components.terncy] unsupported profile 16

rxwen commented 1 year ago

涉及的调光驱动设备的序列号是多少?

lihaoze @.***>于2023年6月15日 周四17:14写道:

ha版本:2023.5.2 问题:小燕网关里面有一个调光模块。第一次添加小燕组件可以正常控制,但是重启后灯光可以读取状态但是无法控制,日志为Unable to find referenced entities light.1 or it is/they are currently not available。然后删除组件,在重新添加组件,小燕网关正常添加,但是调光模块无法发现。日志为: 2023-06-15 17:10:07.027 INFO (MainThread) [custom_components.terncy.config_flow] construct Terncy obj for 1c8259900e36 192.168.2.248 2023-06-15 17:10:10.804 WARNING (MainThread) [custom_components.terncy.config_flow] request a new token form terncy box-1c-82-59-90-0e-36 2023-06-15 17:10:11.414 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityAvailable'} 2023-06-15 17:10:11.415 INFO (MainThread) [custom_components.terncy] [box-1c-82-59-90-0e-36] token-00000017 is available 2023-06-15 17:10:11.418 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityAvailable'} 2023-06-15 17:10:11.418 INFO (MainThread) [custom_components.terncy] [box-1c-82-59-90-0e-36] token-00000017 is available 2023-06-15 17:10:11.421 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityAvailable'} 2023-06-15 17:10:11.421 INFO (MainThread) [custom_components.terncy] [box-1c-82-59-90-0e-36] token-00000017 is available 2023-06-15 17:10:11.425 INFO (MainThread) [custom_components.terncy] update or create entity {'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'} 2023-06-15 17:10:11.426 INFO (MainThread) [custom_components.terncy] update or create entity {'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'} 2023-06-15 17:10:11.427 INFO (MainThread) [custom_components.terncy] update or create entity {'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'} 2023-06-15 17:10:17.120 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityUpdated'} 2023-06-15 17:10:17.120 INFO (MainThread) [custom_components.terncy] unsupported event type entityUpdated 2023-06-15 17:10:17.123 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityUpdated'} 2023-06-15 17:10:17.123 INFO (MainThread) [custom_components.terncy] unsupported event type entityUpdated 2023-06-15 17:10:17.125 INFO (MainThread) [custom_components.terncy] got event message box-1c-82-59-90-0e-36 {'entities': [{'id': 'token-00000017', 'model': 'TERNCY-TOKEN', 'type': 'token'}], 'intent': 'event', 'type': 'entityUpdated'} 2023-06-15 17:10:17.126 INFO (MainThread) [custom_components.terncy] unsupported event type entityUpdated 2023-06-15 17:10:21.256 WARNING (MainThread) [custom_components.terncy.config_flow] token valid, create entry for box-1c-82-59-90-0e-36 2023-06-15 17:10:21.262 INFO (MainThread) [custom_components.terncy] terncy domain async_setup_entry box-1c-82-59-90-0e-36 2023-06-15 17:10:21.263 INFO (MainThread) [custom_components.terncy] start connection to box-1c-82-59-90-0e-36 192.168.2.248 2023-06-15 17:10:21.277 INFO (MainThread) [homeassistant.components.light] Setting up light.terncy 2023-06-15 17:10:21.281 INFO (MainThread) [homeassistant.components.cover] Setting up cover.terncy 2023-06-15 17:10:21.286 INFO (MainThread) [homeassistant.components.switch] Setting up switch.terncy 2023-06-15 17:10:21.291 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.terncy 2023-06-15 17:10:21.297 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.terncy 2023-06-15 17:10:21.305 INFO (MainThread) [terncy.terncy] Terncy v0.3.5 starting connection to: 2023-06-15 17:10:21.305 INFO (MainThread) [terncy.terncy] box-1c-82-59-90-0e-36 192.168.2.248:443 2023-06-15 17:10:21.311 INFO (MainThread) [custom_components.terncy.light] setup terncy light platform 2023-06-15 17:10:21.313 INFO (MainThread) [custom_components.terncy.cover] setup terncy curtain platform 2023-06-15 17:10:21.315 INFO (MainThread) [custom_components.terncy.switch] setup terncy smart plug platform 2023-06-15 17:10:21.317 INFO (MainThread) [custom_components.terncy.binary_sensor] setup terncy curtain platform 2023-06-15 17:10:21.319 INFO (MainThread) [custom_components.terncy.sensor] setup terncy curtain platform 2023-06-15 17:10:21.854 INFO (MainThread) [terncy.terncy] connected to box-1c-82-59-90-0e-36 2023-06-15 17:10:21.855 INFO (MainThread) [custom_components.terncy] got connected event box-1c-82-59-90-0e-36 2023-06-15 17:10:21.859 INFO (MainThread) [custom_components.terncy] refresh devices now 2023-06-15 17:10:21.896 INFO (MainThread) [custom_components.terncy] update or create entity {'hwVersion': 2, 'id': '8cf681fffe4fa7ac-00', 'model': 'TERNCY-ST01-CV', 'online': True, 'ota': -1, 'services': [{'attributes': [{'attr': 'hue', 'value': 246}, {'attr': 'saturation', 'value': 254}, {'attr': 'colorTemperature', 'value': 0}, {'attr': 'brightness', 'value': 0}, {'attr': 'on', 'value': 0}], 'id': '8cf681fffe4fa7ac-01', 'name': '1', 'profile': 27}], 'type': 'device', 'version': 50} 2023-06-15 17:10:21.897 INFO (MainThread) [custom_components.terncy] Updating service {'attributes': [{'attr': 'hue', 'value': 246}, {'attr': 'saturation', 'value': 254}, {'attr': 'colorTemperature', 'value': 0}, {'attr': 'brightness', 'value': 0}, {'attr': 'on', 'value': 0}], 'id': '8cf681fffe4fa7ac-01', 'name': '1', 'profile': 27}, available=True 2023-06-15 17:10:21.897 INFO (MainThread) [custom_components.terncy] need to add dev 1 27 8cf681fffe4fa7ac-01 to platform 2023-06-15 17:10:21.897 INFO (MainThread) [custom_components.terncy] add device 1 of light to light 2023-06-15 17:10:21.907 ERROR (MainThread) [homeassistant.components.light] Platform terncy does not generate unique IDs. ID 8cf681fffe4fa7ac-01 already exists - ignoring light.1 2023-06-15 17:10:21.911 INFO (MainThread) [custom_components.terncy.light] update state event to [{'attr': 'hue', 'value': 246}, {'attr': 'saturation', 'value': 254}, {'attr': 'colorTemperature', 'value': 0}, {'attr': 'brightness', 'value': 0}, {'attr': 'on', 'value': 0}] 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] update or create entity {'hwVersion': 1, 'id': '8cf681fffeba93b1-00', 'model': 'SM0202', 'online': True, 'ota': -1, 'services': [{'attributes': [{'attr': 'battery', 'value': 200}, {'attr': 'iasZoneStatus', 'value': 0}], 'id': '8cf681fffeba93b1-01', 'name': '', 'profile': 21}], 'type': 'device', 'version': 71} 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] Updating service {'attributes': [{'attr': 'battery', 'value': 200}, {'attr': 'iasZoneStatus', 'value': 0}], 'id': '8cf681fffeba93b1-01', 'name': '', 'profile': 21}, available=True 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] unsupported profile 21 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] update or create entity {'hwVersion': 1, 'id': 'box-1c-82-59-90-0e-36', 'model': 'TERNCY-GW02', 'online': True, 'ota': 30187, 'services': [{'attributes': [{'attr': 'volume', 'value': 57}, {'attr': 'playState', 'value': 0}, {'attr': 'mute', 'value': 0}], 'id': 'box-1c-82-59-90-0e-36-01', 'name': '1c8259900e36', 'profile': 16}], 'type': 'device', 'version': 30098} 2023-06-15 17:10:21.912 INFO (MainThread) [custom_components.terncy] Updating service {'attributes': [{'attr': 'volume', 'value': 57}, {'attr': 'playState', 'value': 0}, {'attr': 'mute', 'value': 0}], 'id': 'box-1c-82-59-90-0e-36-01', 'name': '1c8259900e36', 'profile': 16}, available=True 2023-06-15 17:10:21.913 INFO (MainThread) [custom_components.terncy] unsupported profile 16

— Reply to this email directly, view it on GitHub https://github.com/rxwen/homeassistant-terncy-component/issues/38, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADYVFQKMFRAQQS5FBKD7A3XLLG7HANCNFSM6AAAAAAZHRHMRQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Regards, Ruixiong Wen

qweasdzxc54188 commented 1 year ago

@rxwen 产品型号是ST01-CV,序列号是8cf681fffe4fa7ac-01

qweasdzxc54188 commented 1 year ago

class TerncyZCListener: """Terncy zeroconf discovery listener.""" hass=HomeAssistant()

def __init__(self, manager):
    """Create Terncy discovery listener."""
    self.manager = manager

def remove_service(self, zconf, svc_type, name):
    """Get a terncy service removed event."""
    dev_id = name.replace("." + svc_type, "")
    if dev_id in self.manager.hubs:
        del self.manager.hubs[dev_id]
    txt_records = {CONF_DEVID: dev_id}
    # self.manager.hass.bus.async_fire(TERNCY_EVENT_SVC_REMOVE, txt_records)
    TerncyZCListener.hass.bus.async_fire(TERNCY_EVENT_SVC_REMOVE, txt_records)

def update_service(self, zconf, svc_type, name):
    """Get a terncy service updated event."""
    info = zconf.get_service_info(svc_type, name)
    if info is None:
        return
    dev_id = name.replace("." + svc_type, "")
    txt_records = _parse_svc(dev_id, info)

    self.manager.hubs[dev_id] = txt_records
    # self.manager.hass.bus.async_fire(TERNCY_EVENT_SVC_UPDATE, txt_records)
    TerncyZCListener.hass.bus.async_fire(TERNCY_EVENT_SVC_UPDATE, txt_records)

def add_service(self, zconf, svc_type, name):
    """Get a new terncy service discovered event."""
    info = zconf.get_service_info(svc_type, name)
    if info is None:
        return
    dev_id = name.replace("." + svc_type, "")
    ipaddress = ""
    txt_records = {}
    max_retry = 20
    while max_retry > 0:
        max_retry = max_retry - 1
        txt_records = _parse_svc(dev_id, info)
        ipaddress = txt_records[CONF_IP]
        _LOGGER.info("ip address is parsed to %s", ipaddress)
        if not ipaddress == "":
            break
        _LOGGER.warn("ip %s is still not available, query again", ipaddress)
        time.sleep(2)
        info = zconf.get_service_info(svc_type, name)

    self.manager.hubs[dev_id] = txt_records
    # self.manager.hass.bus.async_fire(TERNCY_EVENT_SVC_ADD, txt_records)
    TerncyZCListener.hass.bus.async_fire(TERNCY_EVENT_SVC_ADD, txt_records)

今天调试发现有代码报错,然后我将这三处的代码进行了更改,设备就可以正常的发现 @rxwen

qweasdzxc54188 commented 1 year ago

Exception has occurred: RuntimeError X Non-thread-safe operation invoked on an event loop other than the current one File "/srv/homeassistant/homeassistant/core.py", line 504, in async add hass jobtask = self.loop.create task(hassjob,target(*args), name=hassjob.name)File "/srv/homeassistant/homeassistant/core.py", line 1022, in async fire self. hass.async add hass job(job, event) File "/srv/homeassistant/config/custom components/terncy/hub monitor,py", line 52, in remove serviceself.manager.hass.bus.async fire(TERNCY EVENT SVC REMOVE, txt records)RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one 这个是当时的异常信息

rxwen commented 1 year ago

非常感谢。能否麻烦提供一个PR呢?

On Wed, Jun 21, 2023 at 5:01 PM lihaoze @.***> wrote:

class TerncyZCListener: """Terncy zeroconf discovery listener.""" hass=HomeAssistant()

def init(self, manager): """Create Terncy discovery listener.""" self.manager = manager

def remove_service(self, zconf, svc_type, name): """Get a terncy service removed event.""" dev_id = name.replace("." + svc_type, "") if dev_id in self.manager.hubs: del self.manager.hubs[dev_id] txt_records = {CONF_DEVID: dev_id}

self.manager.hass.bus.async_fire(TERNCY_EVENT_SVC_REMOVE, txt_records)

TerncyZCListener.hass.bus.async_fire(TERNCY_EVENT_SVC_REMOVE, txt_records)

def update_service(self, zconf, svc_type, name): """Get a terncy service updated event.""" info = zconf.get_service_info(svc_type, name) if info is None: return dev_id = name.replace("." + svc_type, "") txt_records = _parse_svc(dev_id, info)

self.manager.hubs[dev_id] = txt_records
# self.manager.hass.bus.async_fire(TERNCY_EVENT_SVC_UPDATE, txt_records)
TerncyZCListener.hass.bus.async_fire(TERNCY_EVENT_SVC_UPDATE, txt_records)

def add_service(self, zconf, svc_type, name): """Get a new terncy service discovered event.""" info = zconf.get_service_info(svc_type, name) if info is None: return dev_id = name.replace("." + svc_type, "") ipaddress = "" txt_records = {} max_retry = 20 while max_retry > 0: max_retry = max_retry - 1 txt_records = _parse_svc(dev_id, info) ipaddress = txt_records[CONF_IP] _LOGGER.info("ip address is parsed to %s", ipaddress) if not ipaddress == "": break _LOGGER.warn("ip %s is still not available, query again", ipaddress) time.sleep(2) info = zconf.get_service_info(svc_type, name)

self.manager.hubs[dev_id] = txt_records
# self.manager.hass.bus.async_fire(TERNCY_EVENT_SVC_ADD, txt_records)
TerncyZCListener.hass.bus.async_fire(TERNCY_EVENT_SVC_ADD, txt_records)

今天调试发现有代码报错,然后我将这三处的代码进行了更改,设备就可以正常的发现

— Reply to this email directly, view it on GitHub https://github.com/rxwen/homeassistant-terncy-component/issues/38#issuecomment-1600463582, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADYVFV4ZQZONZMUFJHURULXMKZ6FANCNFSM6AAAAAAZHRHMRQ . You are receiving this because you were mentioned.Message ID: @.***>

qweasdzxc54188 commented 1 year ago

因为没来的急多测试,我需要多测试几次观察是否正常。很奇怪的是代码其实没有做更改,只是将调用换了一种写法

rxwen commented 1 year ago

可以再验证下 1.0.31 是否还有此问题?