{"action":"created","issue":{"url":"https://api.github.com/repos/danielperna84/home-assistant/issues/14","repository_url":"https://api.github.com/repos/danielperna84/home-assistant","labels_url":"https://api.github.com/repos/danielperna84/home-assistant/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/danielperna84/home-assistant/issues/14/comments","events_url":"https://api.github.com/repos/danielperna84/home-assistant/issues/14/events","html_url":"https://github.com/danielperna84/home-assistant/issues/14","id":162323392,"number":14,"title":"Device creation unreliable ","user":{"login":"Koshu","id":1508787,"avatar_url":"https://avatars.githubusercontent.com/u/1508787?v=3","gravatar_id":"","url":"https://api.github.com/users/Koshu","html_url":"https://github.com/Koshu","followers_url":"https://api.github.com/users/Koshu/followers","following_url":"https://api.github.com/users/Koshu/following{/other_user}","gists_url":"https://api.github.com/users/Koshu/gists{/gist_id}","starred_url":"https://api.github.com/users/Koshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koshu/subscriptions","organizations_url":"https://api.github.com/users/Koshu/orgs","repos_url":"https://api.github.com/users/Koshu/repos","events_url":"https://api.github.com/users/Koshu/events{/privacy}","received_events_url":"https://api.github.com/users/Koshu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-06-26T11:15:30Z","updated_at":"2016-06-26T20:12:37Z","closed_at":null,"body":"After the startup of HA the devices don't always get created correctly.\r\n\r\nThis happens always for an complete category of devices (thermostats, binary_sensors ...). Sometimes only one category, sometimes multiple in any combination.\r\n\r\nWaiting doesn't help, only restarting and hoping that it works this time. If all categories started up correctly everything is working fine, however.\r\n\r\nAs far as I can tell there are no meaningful entries in the debug log. Attached a log of the component full working and one where the binary_sensors failed, anyway.\r\n\r\n[everything_ok.txt](https://github.com/danielperna84/home-assistant/files/333531/everything_ok.txt)\r\n\r\n[binary_sensors_not_detected.txt](https://github.com/danielperna84/home-assistant/files/333532/binary_sensors_not_detected.txt)\r\n\r\nIf you can tell me how, I will try to provide you with more information.\r\n\r\nGreets"},"comment":{"url":"https://api.github.com/repos/danielperna84/home-assistant/issues/comments/228620072","html_url":"https://github.com/danielperna84/home-assistant/issues/14#issuecomment-228620072","issue_url":"https://api.github.com/repos/danielperna84/home-assistant/issues/14","id":228620072,"user":{"login":"Koshu","id":1508787,"avatar_url":"https://avatars.githubusercontent.com/u/1508787?v=3","gravatar_id":"","url":"https://api.github.com/users/Koshu","html_url":"https://github.com/Koshu","followers_url":"https://api.github.com/users/Koshu/followers","following_url":"https://api.github.com/users/Koshu/following{/other_user}","gists_url":"https://api.github.com/users/Koshu/gists{/gist_id}","starred_url":"https://api.github.com/users/Koshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koshu/subscriptions","organizations_url":"https://api.github.com/users/Koshu/orgs","repos_url":"https://api.github.com/users/Koshu/repos","events_url":"https://api.github.com/users/Koshu/events{/privacy}","received_events_url":"https://api.github.com/users/Koshu/received_events","type":"User","site_admin":false},"created_at":"2016-06-26T20:12:37Z","updated_at":"2016-06-26T20:12:37Z","body":"Can try that but i think I found the root of the problem. Just went and spammed my homematic.py with debug messages. Now, I don't have a complete knowledge about the structure of the component, pyhomatic or HA itself, so correct my if my following assumptions are wrong:\r\n\r\nThe functions that came to my attention are system_callback_handler and setup_hmdevice_entity_helper. Now I'm guessing that system_callback_handler is called from the pyhomatic side, while setup_hmdevice_entity_helper is called from the HA side (right?). What ever is the case, what i noticed is, that all device get created where the setup_hmdevice_entity_helper is called before(!) system_callback_handler. All devices where the system_callback_handler is to \"late\" the connection can't be established because in the lines\r\n```\r\n                    for hm_element in HOMEMATIC_DEVICES[dev]:\r\n                        hm_element.link_homematic(delay=delay)\r\n```\r\nthey won't be found. Unless you have the autodiscovery enabled. In that case it gets created anyway but since i never enabled autodiscovery, that didn't work for me.\r\n\r\nThis would also explain, why it only happens with many other components enabled, because it delays the creation of the devices and the call of setup_hmdevice_entity_helper.\r\n\r\nI attached my \"modified\" homematic.py and a logoutput where only the device MEQ0272917 is created, which is the only on with a setup_hmdevice_entity_helper call before the system_callback_handler call.\r\n\r\n[log.txt](https://github.com/danielperna84/home-assistant/files/333794/log.txt)\r\n\r\n\r\n[homematic.py.txt](https://github.com/danielperna84/home-assistant/files/333796/homematic.py.txt)\r\n\r\n\r\nI guess a dirty solution would be to delay the system_callback_handler and a nicer one to track devices in both directions.\r\n\r\nGreets\r\n\r\n"}}
{"actor":{"display_login":"Koshu"}}