{"action":"opened","issue":{"url":"https://api.github.com/repos/tlaukkan/zigbee4java/issues/29","labels_url":"https://api.github.com/repos/tlaukkan/zigbee4java/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/tlaukkan/zigbee4java/issues/29/comments","events_url":"https://api.github.com/repos/tlaukkan/zigbee4java/issues/29/events","html_url":"https://github.com/tlaukkan/zigbee4java/issues/29","id":67963241,"number":29,"title":"Unknown and random device types","user":{"login":"cdjackson","id":1041475,"avatar_url":"https://avatars.githubusercontent.com/u/1041475?v=3","gravatar_id":"","url":"https://api.github.com/users/cdjackson","html_url":"https://github.com/cdjackson","followers_url":"https://api.github.com/users/cdjackson/followers","following_url":"https://api.github.com/users/cdjackson/following{/other_user}","gists_url":"https://api.github.com/users/cdjackson/gists{/gist_id}","starred_url":"https://api.github.com/users/cdjackson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdjackson/subscriptions","organizations_url":"https://api.github.com/users/cdjackson/orgs","repos_url":"https://api.github.com/users/cdjackson/repos","events_url":"https://api.github.com/users/cdjackson/events{/privacy}","received_events_url":"https://api.github.com/users/cdjackson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-12T21:41:49Z","updated_at":"2015-04-12T21:41:49Z","closed_at":null,"body":"I finally got around to chasing down why I get a random device being discovered each time the stack starts for my Hue. My Hue bulbs show an endpoint 242 - it's always been there, and it's a little frustrating in that every time the stack starts it gives this endpoint a different device type - I want to stop this! :)\r\n\r\nThere are really two issues here - firstly, the random selection of device type. This is just plane bad news - in the case of the Hue, where the device isn't known anyway, it doesn't matter, however it means even if the device is known, if it somehow happens to come up with the same score when the factory is evaluating a match, then next time it might evaluate to a different device if it matches two devices with the same score.  In my case, the reason for the randomness is that this device doesn't come up with any score from the factor 'hasMatch'. So, the first class in the factory is the winner and the order isn't defined, so we end up with a random selection each time.  This issue is easily solved by using a map that has a defined order - I've made this modification and will generate a PR soon.\r\n\r\nThe other issue is that returning any device type when the score is 0 is wrong - it hasn't matched any clusters, so we can't really say that this is the device (well, not one that we know!). So, to resolve this I propose to return null from getBestDeviceProxyFactory which stops the device being constructed. \r\n\r\nPR to follow."}}