{"action":"created","comment":{"url":"https://api.github.com/repos/openhab/openhab2-addons/pulls/comments/184661555","pull_request_review_id":115895233,"id":184661555,"diff_hunk":"@@ -0,0 +1,144 @@\n+/**\n+ * Copyright (c) 2010-2017 by the respective copyright holders.\n+ *\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ */\n+\n+package org.openhab.binding.airvisualnode.internal.discovery;\n+\n+import java.net.UnknownHostException;\n+import java.util.Collections;\n+import java.util.concurrent.ScheduledFuture;\n+import java.util.concurrent.TimeUnit;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService;\n+import org.eclipse.smarthome.config.discovery.DiscoveryResult;\n+import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder;\n+import org.eclipse.smarthome.config.discovery.DiscoveryService;\n+import org.eclipse.smarthome.config.discovery.DiscoveryServiceCallback;\n+import org.eclipse.smarthome.config.discovery.ExtendedDiscoveryService;\n+import org.eclipse.smarthome.core.thing.ThingUID;\n+import org.openhab.binding.airvisualnode.AirVisualNodeBindingConstants;\n+import org.openhab.binding.airvisualnode.internal.config.AirVisualNodeConfig;\n+import org.osgi.service.component.annotations.Component;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import jcifs.netbios.NbtAddress;\n+import jcifs.smb.SmbFile;\n+\n+/**\n+ * Autodiscovery for AirVisual Node by searching for a host advertised with the NetBIOS name 'AVISUAL-<SerialNumber>'.\n+ *\n+ * @author Victor Antonovich - Initial contribution\n+ */\n+@Component(service = DiscoveryService.class, immediate = true)\n+public class AirVisualNodeDiscoveryService extends AbstractDiscoveryService implements ExtendedDiscoveryService {\n+\n+    private final Logger logger = LoggerFactory.getLogger(AirVisualNodeDiscoveryService.class);\n+\n+    public static final String AVISUAL_WORKGROUP_NAME = \"MSHOME\";\n+\n+    private static final Pattern AVISUAL_NAME_PATTERN = Pattern.compile(\"^AVISUAL-([^/]+)$\");\n+\n+    private ScheduledFuture<?> backgroundDiscoveryFuture;\n+\n+    private DiscoveryServiceCallback discoveryServiceCallback;\n+\n+    public AirVisualNodeDiscoveryService() {\n+        super(Collections.singleton(AirVisualNodeBindingConstants.THING_TYPE_AVNODE), 600, true);\n+    }\n+\n+    @Override\n+    public void setDiscoveryServiceCallback(DiscoveryServiceCallback discoveryServiceCallback) {\n+        this.discoveryServiceCallback = discoveryServiceCallback;\n+    }\n+\n+    @Override\n+    protected void startScan() {\n+        logger.debug(\"Starting scan\");\n+        scheduler.execute(this::scan);\n+    }\n+\n+    @Override\n+    protected void startBackgroundDiscovery() {\n+        logger.debug(\"Starting background discovery\");\n+        backgroundDiscoveryFuture = scheduler.scheduleWithFixedDelay(this::scan, 0, 300, TimeUnit.SECONDS);\n+    }\n+\n+    @Override\n+    protected void stopBackgroundDiscovery() {\n+        logger.debug(\"Stopping background discovery\");\n+        cancelBackgroundDiscoveryFuture();\n+        super.stopBackgroundDiscovery();\n+    }\n+\n+    private void cancelBackgroundDiscoveryFuture() {\n+        if (backgroundDiscoveryFuture != null && !backgroundDiscoveryFuture.isDone()) {\n+            backgroundDiscoveryFuture.cancel(true);\n+            backgroundDiscoveryFuture = null;\n+        }\n+    }\n+\n+    private void scan() {\n+        // Get all workgroup members\n+        SmbFile[] workgroupMembers;\n+        try {\n+            String workgroupUrl = \"smb://\" + AVISUAL_WORKGROUP_NAME +\"/\";\n+            workgroupMembers = new SmbFile(workgroupUrl).listFiles();\n+        } catch (Exception e) {","path":"addons/binding/org.openhab.binding.airvisualnode/src/main/java/org/openhab/binding/airvisualnode/internal/discovery/AirVisualNodeDiscoveryService.java","position":94,"original_position":94,"commit_id":"949f0dac4c519760b7175bff03b7266b28689094","original_commit_id":"949f0dac4c519760b7175bff03b7266b28689094","user":{"login":"triller-telekom","id":26876013,"avatar_url":"https://avatars3.githubusercontent.com/u/26876013?v=4","gravatar_id":"","url":"https://api.github.com/users/triller-telekom","html_url":"https://github.com/triller-telekom","followers_url":"https://api.github.com/users/triller-telekom/followers","following_url":"https://api.github.com/users/triller-telekom/following{/other_user}","gists_url":"https://api.github.com/users/triller-telekom/gists{/gist_id}","starred_url":"https://api.github.com/users/triller-telekom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/triller-telekom/subscriptions","organizations_url":"https://api.github.com/users/triller-telekom/orgs","repos_url":"https://api.github.com/users/triller-telekom/repos","events_url":"https://api.github.com/users/triller-telekom/events{/privacy}","received_events_url":"https://api.github.com/users/triller-telekom/received_events","type":"User","site_admin":false},"body":"See above, please do not catch `Exception`","created_at":"2018-04-27T11:30:38Z","updated_at":"2018-04-27T11:37:41Z","html_url":"https://github.com/openhab/openhab2-addons/pull/2805#discussion_r184661555","pull_request_url":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/openhab/openhab2-addons/pulls/comments/184661555"},"html":{"href":"https://github.com/openhab/openhab2-addons/pull/2805#discussion_r184661555"},"pull_request":{"href":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805"}}},"pull_request":{"url":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805","id":148670061,"html_url":"https://github.com/openhab/openhab2-addons/pull/2805","diff_url":"https://github.com/openhab/openhab2-addons/pull/2805.diff","patch_url":"https://github.com/openhab/openhab2-addons/pull/2805.patch","issue_url":"https://api.github.com/repos/openhab/openhab2-addons/issues/2805","number":2805,"state":"open","locked":false,"title":"[airvisualnode] Initial contribution for AirVisual Node Binding","user":{"login":"3cky","id":894050,"avatar_url":"https://avatars1.githubusercontent.com/u/894050?v=4","gravatar_id":"","url":"https://api.github.com/users/3cky","html_url":"https://github.com/3cky","followers_url":"https://api.github.com/users/3cky/followers","following_url":"https://api.github.com/users/3cky/following{/other_user}","gists_url":"https://api.github.com/users/3cky/gists{/gist_id}","starred_url":"https://api.github.com/users/3cky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3cky/subscriptions","organizations_url":"https://api.github.com/users/3cky/orgs","repos_url":"https://api.github.com/users/3cky/repos","events_url":"https://api.github.com/users/3cky/events{/privacy}","received_events_url":"https://api.github.com/users/3cky/received_events","type":"User","site_admin":false},"body":"This binding integrates [AirVisual Node Air Quality Monitor](https://airvisual.com/node) with openHAB.\r\n\r\nFor complete information about this binding, please check [Readme.md](https://github.com/3cky/openhab2-addons/blob/airvisual-node-binding/addons/binding/org.openhab.binding.airvisualnode/README.md).\r\n\r\nSigned-off-by: Victor Antonovich <v.antonovich@gmail.com>\r\n","created_at":"2017-10-25T13:37:39Z","updated_at":"2018-04-27T11:37:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"62deb4ee1fb64f9c06408c5fb00c83a0f02049ff","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":159935827,"url":"https://api.github.com/repos/openhab/openhab2-addons/labels/newbinding","name":"newbinding","color":"5319e7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805/commits","review_comments_url":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805/comments","review_comment_url":"https://api.github.com/repos/openhab/openhab2-addons/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openhab/openhab2-addons/issues/2805/comments","statuses_url":"https://api.github.com/repos/openhab/openhab2-addons/statuses/949f0dac4c519760b7175bff03b7266b28689094","head":{"label":"3cky:airvisual-node-binding","ref":"airvisual-node-binding","sha":"949f0dac4c519760b7175bff03b7266b28689094","user":{"login":"3cky","id":894050,"avatar_url":"https://avatars1.githubusercontent.com/u/894050?v=4","gravatar_id":"","url":"https://api.github.com/users/3cky","html_url":"https://github.com/3cky","followers_url":"https://api.github.com/users/3cky/followers","following_url":"https://api.github.com/users/3cky/following{/other_user}","gists_url":"https://api.github.com/users/3cky/gists{/gist_id}","starred_url":"https://api.github.com/users/3cky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3cky/subscriptions","organizations_url":"https://api.github.com/users/3cky/orgs","repos_url":"https://api.github.com/users/3cky/repos","events_url":"https://api.github.com/users/3cky/events{/privacy}","received_events_url":"https://api.github.com/users/3cky/received_events","type":"User","site_admin":false},"repo":{"id":104935031,"name":"openhab2-addons","full_name":"3cky/openhab2-addons","owner":{"login":"3cky","id":894050,"avatar_url":"https://avatars1.githubusercontent.com/u/894050?v=4","gravatar_id":"","url":"https://api.github.com/users/3cky","html_url":"https://github.com/3cky","followers_url":"https://api.github.com/users/3cky/followers","following_url":"https://api.github.com/users/3cky/following{/other_user}","gists_url":"https://api.github.com/users/3cky/gists{/gist_id}","starred_url":"https://api.github.com/users/3cky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3cky/subscriptions","organizations_url":"https://api.github.com/users/3cky/orgs","repos_url":"https://api.github.com/users/3cky/repos","events_url":"https://api.github.com/users/3cky/events{/privacy}","received_events_url":"https://api.github.com/users/3cky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/3cky/openhab2-addons","description":"Add-ons for openHAB 2.x","fork":true,"url":"https://api.github.com/repos/3cky/openhab2-addons","forks_url":"https://api.github.com/repos/3cky/openhab2-addons/forks","keys_url":"https://api.github.com/repos/3cky/openhab2-addons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3cky/openhab2-addons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3cky/openhab2-addons/teams","hooks_url":"https://api.github.com/repos/3cky/openhab2-addons/hooks","issue_events_url":"https://api.github.com/repos/3cky/openhab2-addons/issues/events{/number}","events_url":"https://api.github.com/repos/3cky/openhab2-addons/events","assignees_url":"https://api.github.com/repos/3cky/openhab2-addons/assignees{/user}","branches_url":"https://api.github.com/repos/3cky/openhab2-addons/branches{/branch}","tags_url":"https://api.github.com/repos/3cky/openhab2-addons/tags","blobs_url":"https://api.github.com/repos/3cky/openhab2-addons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3cky/openhab2-addons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3cky/openhab2-addons/git/refs{/sha}","trees_url":"https://api.github.com/repos/3cky/openhab2-addons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3cky/openhab2-addons/statuses/{sha}","languages_url":"https://api.github.com/repos/3cky/openhab2-addons/languages","stargazers_url":"https://api.github.com/repos/3cky/openhab2-addons/stargazers","contributors_url":"https://api.github.com/repos/3cky/openhab2-addons/contributors","subscribers_url":"https://api.github.com/repos/3cky/openhab2-addons/subscribers","subscription_url":"https://api.github.com/repos/3cky/openhab2-addons/subscription","commits_url":"https://api.github.com/repos/3cky/openhab2-addons/commits{/sha}","git_commits_url":"https://api.github.com/repos/3cky/openhab2-addons/git/commits{/sha}","comments_url":"https://api.github.com/repos/3cky/openhab2-addons/comments{/number}","issue_comment_url":"https://api.github.com/repos/3cky/openhab2-addons/issues/comments{/number}","contents_url":"https://api.github.com/repos/3cky/openhab2-addons/contents/{+path}","compare_url":"https://api.github.com/repos/3cky/openhab2-addons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3cky/openhab2-addons/merges","archive_url":"https://api.github.com/repos/3cky/openhab2-addons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3cky/openhab2-addons/downloads","issues_url":"https://api.github.com/repos/3cky/openhab2-addons/issues{/number}","pulls_url":"https://api.github.com/repos/3cky/openhab2-addons/pulls{/number}","milestones_url":"https://api.github.com/repos/3cky/openhab2-addons/milestones{/number}","notifications_url":"https://api.github.com/repos/3cky/openhab2-addons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3cky/openhab2-addons/labels{/name}","releases_url":"https://api.github.com/repos/3cky/openhab2-addons/releases{/id}","deployments_url":"https://api.github.com/repos/3cky/openhab2-addons/deployments","created_at":"2017-09-26T20:35:07Z","updated_at":"2017-09-26T20:35:15Z","pushed_at":"2017-12-07T13:06:18Z","git_url":"git://github.com/3cky/openhab2-addons.git","ssh_url":"git@github.com:3cky/openhab2-addons.git","clone_url":"https://github.com/3cky/openhab2-addons.git","svn_url":"https://github.com/3cky/openhab2-addons","homepage":"","size":263582,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openhab:master","ref":"master","sha":"d3432d7d879003c06f05e000a964e53f3074f0ab","user":{"login":"openhab","id":1007353,"avatar_url":"https://avatars0.githubusercontent.com/u/1007353?v=4","gravatar_id":"","url":"https://api.github.com/users/openhab","html_url":"https://github.com/openhab","followers_url":"https://api.github.com/users/openhab/followers","following_url":"https://api.github.com/users/openhab/following{/other_user}","gists_url":"https://api.github.com/users/openhab/gists{/gist_id}","starred_url":"https://api.github.com/users/openhab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openhab/subscriptions","organizations_url":"https://api.github.com/users/openhab/orgs","repos_url":"https://api.github.com/users/openhab/repos","events_url":"https://api.github.com/users/openhab/events{/privacy}","received_events_url":"https://api.github.com/users/openhab/received_events","type":"Organization","site_admin":false},"repo":{"id":19753195,"name":"openhab2-addons","full_name":"openhab/openhab2-addons","owner":{"login":"openhab","id":1007353,"avatar_url":"https://avatars0.githubusercontent.com/u/1007353?v=4","gravatar_id":"","url":"https://api.github.com/users/openhab","html_url":"https://github.com/openhab","followers_url":"https://api.github.com/users/openhab/followers","following_url":"https://api.github.com/users/openhab/following{/other_user}","gists_url":"https://api.github.com/users/openhab/gists{/gist_id}","starred_url":"https://api.github.com/users/openhab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openhab/subscriptions","organizations_url":"https://api.github.com/users/openhab/orgs","repos_url":"https://api.github.com/users/openhab/repos","events_url":"https://api.github.com/users/openhab/events{/privacy}","received_events_url":"https://api.github.com/users/openhab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openhab/openhab2-addons","description":"Add-ons for openHAB 2.x","fork":false,"url":"https://api.github.com/repos/openhab/openhab2-addons","forks_url":"https://api.github.com/repos/openhab/openhab2-addons/forks","keys_url":"https://api.github.com/repos/openhab/openhab2-addons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openhab/openhab2-addons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openhab/openhab2-addons/teams","hooks_url":"https://api.github.com/repos/openhab/openhab2-addons/hooks","issue_events_url":"https://api.github.com/repos/openhab/openhab2-addons/issues/events{/number}","events_url":"https://api.github.com/repos/openhab/openhab2-addons/events","assignees_url":"https://api.github.com/repos/openhab/openhab2-addons/assignees{/user}","branches_url":"https://api.github.com/repos/openhab/openhab2-addons/branches{/branch}","tags_url":"https://api.github.com/repos/openhab/openhab2-addons/tags","blobs_url":"https://api.github.com/repos/openhab/openhab2-addons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openhab/openhab2-addons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openhab/openhab2-addons/git/refs{/sha}","trees_url":"https://api.github.com/repos/openhab/openhab2-addons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openhab/openhab2-addons/statuses/{sha}","languages_url":"https://api.github.com/repos/openhab/openhab2-addons/languages","stargazers_url":"https://api.github.com/repos/openhab/openhab2-addons/stargazers","contributors_url":"https://api.github.com/repos/openhab/openhab2-addons/contributors","subscribers_url":"https://api.github.com/repos/openhab/openhab2-addons/subscribers","subscription_url":"https://api.github.com/repos/openhab/openhab2-addons/subscription","commits_url":"https://api.github.com/repos/openhab/openhab2-addons/commits{/sha}","git_commits_url":"https://api.github.com/repos/openhab/openhab2-addons/git/commits{/sha}","comments_url":"https://api.github.com/repos/openhab/openhab2-addons/comments{/number}","issue_comment_url":"https://api.github.com/repos/openhab/openhab2-addons/issues/comments{/number}","contents_url":"https://api.github.com/repos/openhab/openhab2-addons/contents/{+path}","compare_url":"https://api.github.com/repos/openhab/openhab2-addons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openhab/openhab2-addons/merges","archive_url":"https://api.github.com/repos/openhab/openhab2-addons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openhab/openhab2-addons/downloads","issues_url":"https://api.github.com/repos/openhab/openhab2-addons/issues{/number}","pulls_url":"https://api.github.com/repos/openhab/openhab2-addons/pulls{/number}","milestones_url":"https://api.github.com/repos/openhab/openhab2-addons/milestones{/number}","notifications_url":"https://api.github.com/repos/openhab/openhab2-addons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openhab/openhab2-addons/labels{/name}","releases_url":"https://api.github.com/repos/openhab/openhab2-addons/releases{/id}","deployments_url":"https://api.github.com/repos/openhab/openhab2-addons/deployments","created_at":"2014-05-13T19:41:58Z","updated_at":"2018-04-26T09:41:44Z","pushed_at":"2018-04-27T10:19:33Z","git_url":"git://github.com/openhab/openhab2-addons.git","ssh_url":"git@github.com:openhab/openhab2-addons.git","clone_url":"https://github.com/openhab/openhab2-addons.git","svn_url":"https://github.com/openhab/openhab2-addons","homepage":"","size":270602,"stargazers_count":766,"watchers_count":766,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1424,"mirror_url":null,"archived":false,"open_issues_count":426,"license":{"key":"epl-1.0","name":"Eclipse Public License 1.0","spdx_id":"EPL-1.0","url":"https://api.github.com/licenses/epl-1.0"},"forks":1424,"open_issues":426,"watchers":766,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805"},"html":{"href":"https://github.com/openhab/openhab2-addons/pull/2805"},"issue":{"href":"https://api.github.com/repos/openhab/openhab2-addons/issues/2805"},"comments":{"href":"https://api.github.com/repos/openhab/openhab2-addons/issues/2805/comments"},"review_comments":{"href":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805/comments"},"review_comment":{"href":"https://api.github.com/repos/openhab/openhab2-addons/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openhab/openhab2-addons/pulls/2805/commits"},"statuses":{"href":"https://api.github.com/repos/openhab/openhab2-addons/statuses/949f0dac4c519760b7175bff03b7266b28689094"}},"author_association":"NONE"}}
{"actor":{"display_login":"triller-telekom"}}