Search in sources :

Example 6 with DeviceDTO

use of org.openhab.binding.myq.internal.dto.DeviceDTO 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)6 OnOffType (org.openhab.core.library.types.OnOffType)2 StringType (org.openhab.core.library.types.StringType)2 Bridge (org.openhab.core.thing.Bridge)2 ThingTypeUID (org.openhab.core.thing.ThingTypeUID)2 BridgeHandler (org.openhab.core.thing.binding.BridgeHandler)2 RefreshType (org.openhab.core.types.RefreshType)2 ArrayList (java.util.ArrayList)1 HttpContentResponse (org.eclipse.jetty.client.HttpContentResponse)1 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)1 AccountDTO (org.openhab.binding.myq.internal.dto.AccountDTO)1 AccountsDTO (org.openhab.binding.myq.internal.dto.AccountsDTO)1 DevicesDTO (org.openhab.binding.myq.internal.dto.DevicesDTO)1 MyQAccountHandler (org.openhab.binding.myq.internal.handler.MyQAccountHandler)1 DiscoveryResult (org.openhab.core.config.discovery.DiscoveryResult)1 PercentType (org.openhab.core.library.types.PercentType)1 UpDownType (org.openhab.core.library.types.UpDownType)1 Thing (org.openhab.core.thing.Thing)1 ThingUID (org.openhab.core.thing.ThingUID)1 ThingHandler (org.openhab.core.thing.binding.ThingHandler)1