當前位置: 首頁>>代碼示例>>Java>>正文


Java HomekitAccessory類代碼示例

本文整理匯總了Java中com.beowulfe.hap.HomekitAccessory的典型用法代碼示例。如果您正苦於以下問題:Java HomekitAccessory類的具體用法?Java HomekitAccessory怎麽用?Java HomekitAccessory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HomekitAccessory類屬於com.beowulfe.hap包,在下文中一共展示了HomekitAccessory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reset

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public synchronized void reset() {
	characteristics.clear();
	services.clear();		
	for (HomekitAccessory accessory: accessories.values()) {
		int iid = 0;
		List<Service> newServices;
		try {
			newServices = new ArrayList<>(2);
			newServices.add(new AccessoryInformationService(accessory));
			newServices.addAll(accessory.getServices());
		} catch (Exception e) {
			logger.error("Could not instantiate services for accessory "+accessory.getLabel(), e);
			services.put(accessory, Collections.emptyList());
			continue;
		}
		Map<Integer, Characteristic> newCharacteristics = new HashMap<>();
		services.put(accessory, newServices);
		for (Service service: newServices) {
			iid++;
			for (Characteristic characteristic: service.getCharacteristics()) {
				newCharacteristics.put(++iid, characteristic);
			}
		}
		characteristics.put(accessory, newCharacteristics);
	}
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:27,代碼來源:HomekitRegistry.java

示例2: AbstractServiceImpl

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
/**
 * <p>Creates a new instance of this class with the specified UUID and {@link HomekitAccessory}.
 * Download and install <i>HomeKit Accessory Simulator</i> to discover the corresponding UUID for
 * the specific service.</p>
 *
 * <p>The new service will automatically add {@link Name} characteristic. If the accessory
 * is battery operated then it must implement {@link BatteryAccessory} and {@link BatteryLevelCharacteristic}
 * will be added too.</p>
 *
 * @param type unique UUID of the service. This information can be obtained from HomeKit Accessory Simulator.
 * @param accessory HomeKit accessory exposed as a service.
 * @param serviceName name of the service. This information is usually the name of the accessory.
    */
public AbstractServiceImpl(String type, HomekitAccessory accessory, String serviceName) {
	this.type = type;

	if (accessory != null) {
		// Add name characteristic
		addCharacteristic(new Name(serviceName));

		// If battery operated accessory then add BatteryLevelCharacteristic
		if (accessory instanceof BatteryAccessory) {
			BatteryAccessory batteryAccessory = (BatteryAccessory) accessory;
			addCharacteristic(new BatteryLevelCharacteristic(
					batteryAccessory::getBatteryLevelState,
					batteryAccessory::subscribeBatteryLevelState,
					batteryAccessory::unsubscribeBatteryLevelState
			));
		}
	}
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:32,代碼來源:AbstractServiceImpl.java

示例3: AccessoryInformationService

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public AccessoryInformationService(HomekitAccessory accessory, String serviceName) throws Exception {
	super("0000003E-0000-1000-8000-0026BB765291", accessory, serviceName);
	addCharacteristic(new Manufacturer(accessory));
	addCharacteristic(new Model(accessory));
	addCharacteristic(new SerialNumber(accessory));
	addCharacteristic(new Identify(accessory));
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:8,代碼來源:AccessoryInformationService.java

示例4: remove

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public void remove(HomekitTaggedItem taggedItem) {
    Iterator<HomekitAccessory> i = createdAccessories.iterator();
    while (i.hasNext()) {
        HomekitAccessory accessory = i.next();
        if (accessory.getId() == taggedItem.getId()) {
            logger.debug("Removed accessory {}", accessory.getId());
            bridge.removeAccessory(accessory);
            i.remove();
        }
    }
}
 
開發者ID:openhab,項目名稱:openhab2-addons,代碼行數:12,代碼來源:HomekitAccessoryRegistry.java

示例5: addRootDevice

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public synchronized void addRootDevice(HomekitAccessory accessory) {
    if (accessory instanceof GroupedAccessory) {
        GroupedAccessory groupedAccessory = (GroupedAccessory) accessory;
        pendingGroupedAccessories.put(groupedAccessory.getGroupName(), groupedAccessory);
        for (HomekitTaggedItem characteristic : pendingCharacteristics) {
            if (characteristic.getItem().getGroupNames().contains(groupedAccessory.getGroupName())) {
                addCharacteristicToGroup(groupedAccessory.getGroupName(), characteristic);
            }
        }
    } else {
        doAddDevice(accessory);
    }
}
 
開發者ID:openhab,項目名稱:openhab2-addons,代碼行數:14,代碼來源:HomekitAccessoryRegistry.java

示例6: doAddDevice

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
private void doAddDevice(HomekitAccessory accessory) {
    createdAccessories.add(accessory);
    createdIds.add(accessory.getId());
    if (bridge != null) {
        bridge.addAccessory(accessory);
    }
    logger.debug("Added accessory {}", accessory.getId());
}
 
開發者ID:openhab,項目名稱:openhab2-addons,代碼行數:9,代碼來源:HomekitAccessoryRegistry.java

示例7: create

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public static HomekitAccessory create(HomekitTaggedItem taggedItem, ItemRegistry itemRegistry,
        HomekitAccessoryUpdater updater, HomekitSettings settings) throws Exception {
    switch (taggedItem.getDeviceType()) {
        case LIGHTBULB:
            return new HomekitLightbulbImpl(taggedItem, itemRegistry, updater);

        case DIMMABLE_LIGHTBULB:
            return new HomekitDimmableLightbulbImpl(taggedItem, itemRegistry, updater);

        case COLORFUL_LIGHTBULB:
            return new HomekitColorfulLightbulbImpl(taggedItem, itemRegistry, updater);

        case THERMOSTAT:
            return new HomekitThermostatImpl(taggedItem, itemRegistry, updater, settings);

        case SWITCH:
            return new HomekitSwitchImpl(taggedItem, itemRegistry, updater);

        case TEMPERATURE_SENSOR:
            return new HomekitTemperatureSensorImpl(taggedItem, itemRegistry, updater, settings);

        case HUMIDITY_SENSOR:
            return new HomekitHumiditySensorImpl(taggedItem, itemRegistry, updater);
    }

    throw new Exception("Unknown homekit type: " + taggedItem.getDeviceType());
}
 
開發者ID:openhab,項目名稱:openhab2-addons,代碼行數:28,代碼來源:HomekitAccessoryFactory.java

示例8: addAccessory

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public void addAccessory(HomekitAccessory homekitAccessory) {
    hapServer.getBridge().addAccessory(homekitAccessory);
    System.out.println("Loading: " + homekitAccessory.getLabel());
}
 
開發者ID:podpage,項目名稱:Java-HAP-Server,代碼行數:5,代碼來源:AccessoryManager.java

示例9: SessionKey

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public SessionKey(InetAddress address, HomekitAccessory accessory) {
	this.address = address;
	this.accessory = accessory;
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:5,代碼來源:HttpSession.java

示例10: getAccessories

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public Collection<HomekitAccessory> getAccessories() {
	return accessories.values();
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:4,代碼來源:HomekitRegistry.java

示例11: add

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public void add(HomekitAccessory accessory) {
	accessories.put(accessory.getId(), accessory);
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:4,代碼來源:HomekitRegistry.java

示例12: remove

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public void remove(HomekitAccessory accessory) {
	accessories.remove(accessory.getId());
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:4,代碼來源:HomekitRegistry.java

示例13: Identify

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public Identify(HomekitAccessory accessory) throws Exception {
	super("00000014-0000-1000-8000-0026BB765291",
			"Identifies the accessory via a physical action on the accessory");
	this.accessory = accessory;
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:6,代碼來源:Identify.java

示例14: Model

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public Model(HomekitAccessory accessory) throws Exception {
	super("00000021-0000-1000-8000-0026BB765291", 
			"The name of the model",
			accessory.getModel());
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:6,代碼來源:Model.java

示例15: Manufacturer

import com.beowulfe.hap.HomekitAccessory; //導入依賴的package包/類
public Manufacturer(HomekitAccessory accessory) throws Exception {
	super("00000020-0000-1000-8000-0026BB765291", 
			"The name of the manufacturer",
			accessory.getManufacturer());
}
 
開發者ID:beowulfe,項目名稱:HAP-Java,代碼行數:6,代碼來源:Manufacturer.java


注:本文中的com.beowulfe.hap.HomekitAccessory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。