Search in sources :

Example 1 with MyQAccountHandler

use of org.openhab.binding.myq.internal.handler.MyQAccountHandler in project openhab-addons by openhab.

the class MyQDiscoveryService method startScan.

@Override
public void startScan() {
    MyQAccountHandler accountHandler = this.accountHandler;
    if (accountHandler != null) {
        List<DeviceDTO> devices = accountHandler.devicesCache();
        if (devices != null) {
            devices.forEach(device -> {
                ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, device.deviceFamily);
                if (SUPPORTED_DISCOVERY_THING_TYPES_UIDS.contains(thingTypeUID)) {
                    ThingUID thingUID = new ThingUID(thingTypeUID, accountHandler.getThing().getUID(), device.serialNumber.toLowerCase());
                    DiscoveryResult result = DiscoveryResultBuilder.create(thingUID).withLabel("MyQ " + device.name).withProperty(Thing.PROPERTY_SERIAL_NUMBER, thingUID.getId()).withRepresentationProperty(Thing.PROPERTY_SERIAL_NUMBER).withBridge(accountHandler.getThing().getUID()).build();
                    thingDiscovered(result);
                }
            });
        }
    }
}
Also used : MyQAccountHandler(org.openhab.binding.myq.internal.handler.MyQAccountHandler) DiscoveryResult(org.openhab.core.config.discovery.DiscoveryResult) ThingUID(org.openhab.core.thing.ThingUID) ThingTypeUID(org.openhab.core.thing.ThingTypeUID) DeviceDTO(org.openhab.binding.myq.internal.dto.DeviceDTO)

Aggregations

DeviceDTO (org.openhab.binding.myq.internal.dto.DeviceDTO)1 MyQAccountHandler (org.openhab.binding.myq.internal.handler.MyQAccountHandler)1 DiscoveryResult (org.openhab.core.config.discovery.DiscoveryResult)1 ThingTypeUID (org.openhab.core.thing.ThingTypeUID)1 ThingUID (org.openhab.core.thing.ThingUID)1