mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-27 07:41:39 +01:00
Signed-off-by: Jeff Lauterbach <jjlauterbach@gmail.com>
This commit is contained in:
parent
706af08fb6
commit
c4887f30f2
@ -42,14 +42,15 @@ public class NeatoAccountDiscoveryService extends AbstractDiscoveryService {
|
|||||||
|
|
||||||
private static final int TIMEOUT = 15;
|
private static final int TIMEOUT = 15;
|
||||||
|
|
||||||
private NeatoAccountHandler handler;
|
private final NeatoAccountHandler handler;
|
||||||
private ThingUID bridgeUID;
|
private final ThingUID bridgeUID;
|
||||||
|
|
||||||
private ScheduledFuture<?> scanTask;
|
private ScheduledFuture<?> scanTask;
|
||||||
|
|
||||||
public NeatoAccountDiscoveryService(NeatoAccountHandler handler) {
|
public NeatoAccountDiscoveryService(NeatoAccountHandler handler) {
|
||||||
super(NeatoHandlerFactory.DISCOVERABLE_THING_TYPE_UIDS, TIMEOUT);
|
super(NeatoHandlerFactory.DISCOVERABLE_THING_TYPE_UIDS, TIMEOUT);
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
|
this.bridgeUID = handler.getThing().getUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findRobots() {
|
private void findRobots() {
|
||||||
@ -70,7 +71,7 @@ public class NeatoAccountDiscoveryService extends AbstractDiscoveryService {
|
|||||||
if (this.scanTask != null) {
|
if (this.scanTask != null) {
|
||||||
scanTask.cancel(true);
|
scanTask.cancel(true);
|
||||||
}
|
}
|
||||||
this.scanTask = scheduler.schedule(() -> findRobots(), 0, TimeUnit.SECONDS);
|
this.scanTask = scheduler.schedule(this::findRobots, 0, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,17 +89,16 @@ public class NeatoAccountDiscoveryService extends AbstractDiscoveryService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("addThing(): Adding new Neato unit {} to the inbox", robot.getName());
|
logger.debug("addThing(): Adding new Neato unit ({}) to the inbox", robot.getName());
|
||||||
|
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
String serial = robot.getSerial();
|
|
||||||
ThingUID thingUID = new ThingUID(NeatoBindingConstants.THING_TYPE_VACUUMCLEANER, bridgeUID, robot.getSerial());
|
ThingUID thingUID = new ThingUID(NeatoBindingConstants.THING_TYPE_VACUUMCLEANER, bridgeUID, robot.getSerial());
|
||||||
properties.put(NeatoBindingConstants.CONFIG_SECRET, robot.getSecretKey());
|
properties.put(NeatoBindingConstants.CONFIG_SECRET, robot.getSecretKey());
|
||||||
properties.put(NeatoBindingConstants.CONFIG_SERIAL, robot.getSerial());
|
properties.put(NeatoBindingConstants.CONFIG_SERIAL, robot.getSerial());
|
||||||
properties.put(Thing.PROPERTY_MODEL_ID, robot.getModel());
|
properties.put(Thing.PROPERTY_MODEL_ID, robot.getModel());
|
||||||
properties.put(NeatoBindingConstants.PROPERTY_NAME, robot.getName());
|
properties.put(NeatoBindingConstants.PROPERTY_NAME, robot.getName());
|
||||||
|
|
||||||
thingDiscovered(
|
thingDiscovered(DiscoveryResultBuilder.create(thingUID).withLabel(robot.getName()).withBridge(bridgeUID)
|
||||||
DiscoveryResultBuilder.create(thingUID).withBridge(bridgeUID).withProperties(properties).build());
|
.withProperties(properties).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user