{"action":"created","issue":{"url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/issues/105","repository_url":"https://api.github.com/repos/Koenkk/zigbee2mqtt","labels_url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/issues/105/labels{/name}","comments_url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/issues/105/comments","events_url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/issues/105/events","html_url":"https://github.com/Koenkk/zigbee2mqtt/issues/105","id":330867443,"node_id":"MDU6SXNzdWUzMzA4Njc0NDM=","number":105,"title":"Lost Sensors after HA Restart with Auto-discovery Enabled","user":{"login":"jarrah31","id":3072303,"node_id":"MDQ6VXNlcjMwNzIzMDM=","avatar_url":"https://avatars3.githubusercontent.com/u/3072303?v=4","gravatar_id":"","url":"https://api.github.com/users/jarrah31","html_url":"https://github.com/jarrah31","followers_url":"https://api.github.com/users/jarrah31/followers","following_url":"https://api.github.com/users/jarrah31/following{/other_user}","gists_url":"https://api.github.com/users/jarrah31/gists{/gist_id}","starred_url":"https://api.github.com/users/jarrah31/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarrah31/subscriptions","organizations_url":"https://api.github.com/users/jarrah31/orgs","repos_url":"https://api.github.com/users/jarrah31/repos","events_url":"https://api.github.com/users/jarrah31/events{/privacy}","received_events_url":"https://api.github.com/users/jarrah31/received_events","type":"User","site_admin":false},"labels":[{"id":894537366,"node_id":"MDU6TGFiZWw4OTQ1MzczNjY=","url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/labels/enhancement","name":"enhancement","color":"a2eeef","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/milestones/1","html_url":"https://github.com/Koenkk/zigbee2mqtt/milestone/1","labels_url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/milestones/1/labels","id":3404085,"node_id":"MDk6TWlsZXN0b25lMzQwNDA4NQ==","number":1,"title":"0.1","description":"","creator":{"login":"Koenkk","id":2892853,"node_id":"MDQ6VXNlcjI4OTI4NTM=","avatar_url":"https://avatars0.githubusercontent.com/u/2892853?v=4","gravatar_id":"","url":"https://api.github.com/users/Koenkk","html_url":"https://github.com/Koenkk","followers_url":"https://api.github.com/users/Koenkk/followers","following_url":"https://api.github.com/users/Koenkk/following{/other_user}","gists_url":"https://api.github.com/users/Koenkk/gists{/gist_id}","starred_url":"https://api.github.com/users/Koenkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koenkk/subscriptions","organizations_url":"https://api.github.com/users/Koenkk/orgs","repos_url":"https://api.github.com/users/Koenkk/repos","events_url":"https://api.github.com/users/Koenkk/events{/privacy}","received_events_url":"https://api.github.com/users/Koenkk/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":2,"state":"open","created_at":"2018-06-06T06:13:48Z","updated_at":"2018-06-10T15:41:47Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2018-06-09T08:47:24Z","updated_at":"2018-06-11T19:08:11Z","closed_at":null,"author_association":"NONE","body":"I would like to find out if this is normal behaviour and whether there's a solution please?\r\n\r\nI have auto-discovery enabled on HA and Z2M (zigbee2mqtt - quicker to type!) ;)\r\nZ2M:\r\n```homeassistant: true```\r\nHA:\r\n```\r\nmqtt:\r\n  discovery: true\r\n```\r\nIf I restart Z2M the sensors automatically appear in HA which works well. However, if I restart HA (after doing some yaml config), the sensors disappear! I then have to also restart Z2M to add them back into HA.\r\n\r\nIf this is expected behaviour (do others see this too?), perhaps a solution is to publish the sensors back to HA when Z2M detects a restart. For example, I notice in Z2M logs the following occurs during a HA reboot:\r\n```\r\nJun 09 09:26:35 zigbeepi npm[2813]: 2018-6-9 09:26:35 ERROR Not connected to MQTT server!\r\nJun 09 09:26:45 zigbeepi npm[2813]: 2018-6-9 09:26:45 ERROR Not connected to MQTT server!\r\nJun 09 09:26:55 zigbeepi npm[2813]: 2018-6-9 09:26:55 ERROR Not connected to MQTT server!\r\nJun 09 09:27:05 zigbeepi npm[2813]: 2018-6-9 09:27:05 ERROR Not connected to MQTT server!\r\nJun 09 09:27:07 zigbeepi npm[2813]: 2018-6-9 09:27:07 INFO Connected to MQTT server\r\nJun 09 09:27:07 zigbeepi npm[2813]: 2018-6-9 09:27:07 INFO MQTT publish, topic: 'zigbee2mqtt/bridge/state', payload: 'online'\r\nJun 09 09:27:07 zigbeepi npm[2813]: 2018-6-9 09:27:07 WARN `permit_join` set to  `true` in configuration.yaml.\r\nJun 09 09:27:07 zigbeepi npm[2813]: 2018-6-9 09:27:07 WARN Allowing new devices to join.\r\nJun 09 09:27:07 zigbeepi npm[2813]: 2018-6-9 09:27:07 WARN Set `permit_join` to `false` once you joined all devices.\r\nJun 09 09:27:07 zigbeepi npm[2813]: 2018-6-9 09:27:07 INFO Zigbee: allowing new devices to join.\r\n```\r\nAt the point where it says `INFO Connected to MQTT server`, could the sensors be published back to HA (it may need a delay if HA isn't ready just then)? e.g. like this:\r\n```\r\nJun 09 09:25:49 zigbeepi npm[2813]: 2018-6-9 09:25:49 INFO MQTT publish, topic: 'homeassistant/binary_sensor/0x00158d0001b149eb/contact/config', payload: '{\"payload_on\":false,\"payload_off\":true,\"value_template\":\"{{ value_json.contact }}\",\"device_class\":\"door\",\"json_attributes\":[\"battery\",\"voltage\"],\"state_topic\":\"zigbee2mqtt/window_ensuite_velux\",\"availability_topic\":\"zigbee2mqtt/bridge/state\",\"name\":\"window_ensuite_velux\",\"unique_id\":\"0x00158d0001b149eb_contact_zigbee2mqtt\"}'\r\n```"},"comment":{"url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/issues/comments/396352525","html_url":"https://github.com/Koenkk/zigbee2mqtt/issues/105#issuecomment-396352525","issue_url":"https://api.github.com/repos/Koenkk/zigbee2mqtt/issues/105","id":396352525,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjM1MjUyNQ==","user":{"login":"ciotlosm","id":7738048,"node_id":"MDQ6VXNlcjc3MzgwNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/7738048?v=4","gravatar_id":"","url":"https://api.github.com/users/ciotlosm","html_url":"https://github.com/ciotlosm","followers_url":"https://api.github.com/users/ciotlosm/followers","following_url":"https://api.github.com/users/ciotlosm/following{/other_user}","gists_url":"https://api.github.com/users/ciotlosm/gists{/gist_id}","starred_url":"https://api.github.com/users/ciotlosm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciotlosm/subscriptions","organizations_url":"https://api.github.com/users/ciotlosm/orgs","repos_url":"https://api.github.com/users/ciotlosm/repos","events_url":"https://api.github.com/users/ciotlosm/events{/privacy}","received_events_url":"https://api.github.com/users/ciotlosm/received_events","type":"User","site_admin":false},"created_at":"2018-06-11T19:08:11Z","updated_at":"2018-06-11T19:08:11Z","author_association":"NONE","body":"I've checked with temperature sensor and cube and seams to work 👍 "}}
{"actor":{"display_login":"ciotlosm"}}