You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- adapted to new 1.8.1+ API scheme of whitelist usernames being
assigned by the bridge.
The assigned username is stored using Java Preferences. The scheme
should be compatible
with already authorized hue2mqtt instances, which used a hardcoded
username of "hue2mqttuser".
- Hue API libraries updated to 0.11.2.
L.info("Saved whitelist username "+u+" for Bridge IP "+bridgeIp);
42
+
}
43
+
44
+
16
45
staticvoidinit()
17
46
{
18
47
instance=newHueHandler();
@@ -31,8 +60,9 @@ static void init()
31
60
else
32
61
{
33
62
PHAccessPointpap=newPHAccessPoint();
63
+
usedBridgeIP=specifiedBridge;
34
64
pap.setIpAddress(specifiedBridge);
35
-
pap.setUsername("huetomqttuser");
65
+
pap.setUsername(readUsername(specifiedBridge));
36
66
instance.connect(pap);
37
67
}
38
68
}
@@ -64,8 +94,10 @@ public void onAccessPointsFound(List<PHAccessPoint> bridges)
64
94
L.warning("Multiple bridges found. Will connect to the first bridge. This may not be what you want! Specify the bridge you want to connect to explicitely with hue.bridge=<name or ip>");
65
95
}
66
96
PHAccessPointpap=bridges.get(0);
67
-
pap.setUsername("huetomqttuser");
68
-
L.info("Connecting to Hue bridge @ "+pap.getIpAddress());
97
+
usedBridgeIP=pap.getIpAddress();
98
+
Stringusername=readUsername(usedBridgeIP);
99
+
pap.setUsername(username);
100
+
L.info("Connecting to Hue bridge @ "+pap.getIpAddress()+" with username "+username);
69
101
connect(pap);
70
102
}
71
103
@@ -136,7 +168,13 @@ public void onConnectionResumed(PHBridge b)
136
168
@Override
137
169
publicvoidonError(inte, Stringmsg)
138
170
{
139
-
L.warning("Error in bridge connection. Code "+e+": "+msg);
171
+
if(e==101)
172
+
{
173
+
/* This is "Authentication required", we silently ignore it here */
174
+
return;
175
+
}
176
+
177
+
L.warning("Error in bridge connection. Code "+e+": "+msg+"; will reconnect in 10s");
140
178
/* Retry connection in 10s */
141
179
Main.t.schedule(newTimerTask(){
142
180
@Override
@@ -343,6 +381,7 @@ public void onBridgeConnected(PHBridge b, String name)
343
381
{
344
382
L.info("Successfully connected to Hue bridge as "+name);
0 commit comments