2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.io.homekit.internal.accessories;
15 import static org.openhab.io.homekit.internal.HomekitAccessoryType.*;
16 import static org.openhab.io.homekit.internal.HomekitCharacteristicType.*;
18 import java.lang.reflect.InvocationTargetException;
19 import java.util.AbstractMap.SimpleEntry;
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.List;
26 import java.util.Map.Entry;
27 import java.util.Optional;
28 import java.util.stream.Collectors;
29 import java.util.stream.Stream;
31 import org.eclipse.jdt.annotation.NonNullByDefault;
32 import org.eclipse.jdt.annotation.Nullable;
33 import org.openhab.core.items.GenericItem;
34 import org.openhab.core.items.GroupItem;
35 import org.openhab.core.items.Item;
36 import org.openhab.core.items.ItemRegistry;
37 import org.openhab.core.items.Metadata;
38 import org.openhab.core.items.MetadataKey;
39 import org.openhab.core.items.MetadataRegistry;
40 import org.openhab.core.library.items.ColorItem;
41 import org.openhab.core.library.items.DimmerItem;
42 import org.openhab.io.homekit.internal.HomekitAccessoryType;
43 import org.openhab.io.homekit.internal.HomekitAccessoryUpdater;
44 import org.openhab.io.homekit.internal.HomekitCharacteristicType;
45 import org.openhab.io.homekit.internal.HomekitException;
46 import org.openhab.io.homekit.internal.HomekitOHItemProxy;
47 import org.openhab.io.homekit.internal.HomekitSettings;
48 import org.openhab.io.homekit.internal.HomekitTaggedItem;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
52 import io.github.hapjava.accessories.HomekitAccessory;
53 import io.github.hapjava.characteristics.Characteristic;
54 import io.github.hapjava.services.Service;
57 * Creates a HomekitAccessory for a given HomekitTaggedItem.
59 * @author Andy Lintner - Initial contribution
60 * @author Eugen Freiter - refactoring for optional characteristics
63 @SuppressWarnings("deprecation")
64 public class HomekitAccessoryFactory {
65 private static final Logger logger = LoggerFactory.getLogger(HomekitAccessoryFactory.class);
66 public final static String METADATA_KEY = "homekit"; // prefix for HomeKit meta information in items.xml
68 /** List of mandatory attributes for each accessory type. **/
69 private final static Map<HomekitAccessoryType, HomekitCharacteristicType[]> MANDATORY_CHARACTERISTICS = new HashMap<HomekitAccessoryType, HomekitCharacteristicType[]>() {
71 put(LEAK_SENSOR, new HomekitCharacteristicType[] { LEAK_DETECTED_STATE });
72 put(MOTION_SENSOR, new HomekitCharacteristicType[] { MOTION_DETECTED_STATE });
73 put(OCCUPANCY_SENSOR, new HomekitCharacteristicType[] { OCCUPANCY_DETECTED_STATE });
74 put(CONTACT_SENSOR, new HomekitCharacteristicType[] { CONTACT_SENSOR_STATE });
75 put(SMOKE_SENSOR, new HomekitCharacteristicType[] { SMOKE_DETECTED_STATE });
76 put(HUMIDITY_SENSOR, new HomekitCharacteristicType[] { RELATIVE_HUMIDITY });
77 put(AIR_QUALITY_SENSOR, new HomekitCharacteristicType[] { AIR_QUALITY });
78 put(SWITCH, new HomekitCharacteristicType[] { ON_STATE });
79 put(CARBON_DIOXIDE_SENSOR, new HomekitCharacteristicType[] { CARBON_DIOXIDE_DETECTED_STATE });
80 put(CARBON_MONOXIDE_SENSOR, new HomekitCharacteristicType[] { CARBON_MONOXIDE_DETECTED_STATE });
81 put(WINDOW_COVERING, new HomekitCharacteristicType[] { TARGET_POSITION, CURRENT_POSITION, POSITION_STATE });
82 put(LIGHTBULB, new HomekitCharacteristicType[] { ON_STATE });
83 put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS });
84 put(LIGHT_SENSOR, new HomekitCharacteristicType[] { LIGHT_LEVEL });
85 put(TEMPERATURE_SENSOR, new HomekitCharacteristicType[] { CURRENT_TEMPERATURE });
86 put(THERMOSTAT, new HomekitCharacteristicType[] { CURRENT_HEATING_COOLING_STATE,
87 TARGET_HEATING_COOLING_STATE, CURRENT_TEMPERATURE, TARGET_TEMPERATURE });
88 put(LOCK, new HomekitCharacteristicType[] { LOCK_CURRENT_STATE, LOCK_TARGET_STATE });
89 put(VALVE, new HomekitCharacteristicType[] { ACTIVE_STATUS, INUSE_STATUS });
91 new HomekitCharacteristicType[] { SECURITY_SYSTEM_CURRENT_STATE, SECURITY_SYSTEM_TARGET_STATE });
92 put(OUTLET, new HomekitCharacteristicType[] { ON_STATE, INUSE_STATUS });
93 put(SPEAKER, new HomekitCharacteristicType[] { MUTE });
94 put(GARAGE_DOOR_OPENER,
95 new HomekitCharacteristicType[] { CURRENT_DOOR_STATE, TARGET_DOOR_STATE, OBSTRUCTION_STATUS });
96 put(HEATER_COOLER, new HomekitCharacteristicType[] { ACTIVE_STATUS, CURRENT_HEATER_COOLER_STATE,
97 TARGET_HEATER_COOLER_STATE, CURRENT_TEMPERATURE });
99 put(BLINDS, new HomekitCharacteristicType[] { TARGET_POSITION, CURRENT_POSITION, POSITION_STATE });
100 put(WINDOW, new HomekitCharacteristicType[] { CURRENT_POSITION, TARGET_POSITION, POSITION_STATE });
101 put(DOOR, new HomekitCharacteristicType[] { CURRENT_POSITION, TARGET_POSITION, POSITION_STATE });
103 put(OLD_HUMIDITY_SENSOR, new HomekitCharacteristicType[] { RELATIVE_HUMIDITY });
104 put(OLD_DIMMABLE_LIGHTBULB, new HomekitCharacteristicType[] { ON_STATE });
105 put(OLD_COLORFUL_LIGHTBULB, new HomekitCharacteristicType[] { ON_STATE });
109 /** List of service implementation for each accessory type. **/
110 private final static Map<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>> SERVICE_IMPL_MAP = new HashMap<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>>() {
112 put(LEAK_SENSOR, HomekitLeakSensorImpl.class);
113 put(MOTION_SENSOR, HomekitMotionSensorImpl.class);
114 put(OCCUPANCY_SENSOR, HomekitOccupancySensorImpl.class);
115 put(CONTACT_SENSOR, HomekitContactSensorImpl.class);
116 put(SMOKE_SENSOR, HomekitSmokeSensorImpl.class);
117 put(HUMIDITY_SENSOR, HomekitHumiditySensorImpl.class);
118 put(AIR_QUALITY_SENSOR, HomekitAirQualitySensorImpl.class);
119 put(SWITCH, HomekitSwitchImpl.class);
120 put(CARBON_DIOXIDE_SENSOR, HomekitCarbonDioxideSensorImpl.class);
121 put(CARBON_MONOXIDE_SENSOR, HomekitCarbonMonoxideSensorImpl.class);
122 put(WINDOW_COVERING, HomekitWindowCoveringImpl.class);
123 put(LIGHTBULB, HomekitLightbulbImpl.class);
124 put(FAN, HomekitFanImpl.class);
125 put(LIGHT_SENSOR, HomekitLightSensorImpl.class);
126 put(TEMPERATURE_SENSOR, HomekitTemperatureSensorImpl.class);
127 put(THERMOSTAT, HomekitThermostatImpl.class);
128 put(LOCK, HomekitLockImpl.class);
129 put(VALVE, HomekitValveImpl.class);
130 put(SECURITY_SYSTEM, HomekitSecuritySystemImpl.class);
131 put(OUTLET, HomekitOutletImpl.class);
132 put(SPEAKER, HomekitSpeakerImpl.class);
133 put(GARAGE_DOOR_OPENER, HomekitGarageDoorOpenerImpl.class);
134 put(BLINDS, HomekitWindowCoveringImpl.class);
135 put(DOOR, HomekitDoorImpl.class);
136 put(WINDOW, HomekitWindowImpl.class);
137 put(HEATER_COOLER, HomekitHeaterCoolerImpl.class);
138 put(OLD_HUMIDITY_SENSOR, HomekitHumiditySensorImpl.class);
139 put(OLD_DIMMABLE_LIGHTBULB, HomekitLightbulbImpl.class);
140 put(OLD_COLORFUL_LIGHTBULB, HomekitLightbulbImpl.class);
144 /** mapping of legacy attributes to new attributes. **/
145 private final static Map<HomekitCharacteristicType, HomekitCharacteristicType> LEGACY_CHARACTERISTICS_MAPPING = new HashMap<HomekitCharacteristicType, HomekitCharacteristicType>() {
147 put(OLD_CURRENT_HEATING_COOLING_STATE, CURRENT_HEATING_COOLING_STATE);
148 put(OLD_TARGET_HEATING_COOLING_MODE, TARGET_HEATING_COOLING_STATE);
149 put(OLD_TARGET_TEMPERATURE, TARGET_TEMPERATURE);
150 put(OLD_BATTERY_LOW_STATUS, BATTERY_LOW_STATUS);
151 put(VERY_OLD_TARGET_HEATING_COOLING_MODE, CURRENT_HEATING_COOLING_STATE);
155 /** list of optional implicit optional characteristics. mainly used for legacy accessory type */
156 private final static Map<HomekitAccessoryType, HomekitCharacteristicType[]> IMPLICIT_OPTIONAL_CHARACTERISTICS = new HashMap<HomekitAccessoryType, HomekitCharacteristicType[]>() {
158 put(OLD_DIMMABLE_LIGHTBULB, new HomekitCharacteristicType[] { BRIGHTNESS });
159 put(OLD_COLORFUL_LIGHTBULB, new HomekitCharacteristicType[] { HUE, SATURATION, BRIGHTNESS });
165 * creates HomeKit accessory for a openhab item.
167 * @param taggedItem openhab item tagged as HomeKit item
168 * @param metadataRegistry openhab metadata registry required to get item meta information
169 * @param updater OH HomeKit update class that ensure the status sync between OH item and corresponding HomeKit
171 * @param settings OH settings
172 * @return HomeKit accessory
173 * @throws HomekitException exception in case HomeKit accessory could not be created, e.g. due missing mandatory
176 @SuppressWarnings("null")
177 public static HomekitAccessory create(HomekitTaggedItem taggedItem, MetadataRegistry metadataRegistry,
178 HomekitAccessoryUpdater updater, HomekitSettings settings) throws HomekitException {
179 final HomekitAccessoryType accessoryType = taggedItem.getAccessoryType();
180 logger.trace("Constructing {} of accessory type {}", taggedItem.getName(), accessoryType.getTag());
181 final List<HomekitTaggedItem> requiredCharacteristics = getMandatoryCharacteristics(taggedItem,
183 final HomekitCharacteristicType[] mandatoryCharacteristics = MANDATORY_CHARACTERISTICS.get(accessoryType);
184 if ((mandatoryCharacteristics != null) && (requiredCharacteristics.size() < mandatoryCharacteristics.length)) {
185 logger.warn("Accessory of type {} must have following characteristics {}. Found only {}",
186 accessoryType.getTag(), mandatoryCharacteristics, requiredCharacteristics);
187 throw new HomekitException("Missing mandatory characteristics");
189 AbstractHomekitAccessoryImpl accessoryImpl;
191 final @Nullable Class<? extends AbstractHomekitAccessoryImpl> accessoryImplClass = SERVICE_IMPL_MAP
193 if (accessoryImplClass != null) {
194 accessoryImpl = accessoryImplClass
195 .getConstructor(HomekitTaggedItem.class, List.class, HomekitAccessoryUpdater.class,
196 HomekitSettings.class)
197 .newInstance(taggedItem, requiredCharacteristics, updater, settings);
198 addOptionalCharacteristics(taggedItem, accessoryImpl, metadataRegistry);
199 return accessoryImpl;
201 logger.warn("Unsupported HomeKit type: {}", accessoryType.getTag());
202 throw new HomekitException("Unsupported HomeKit type: " + accessoryType);
204 } catch (NoSuchMethodException | IllegalAccessException | InstantiationException
205 | InvocationTargetException e) {
206 logger.warn("Cannot instantiate accessory implementation for accessory {}", accessoryType.getTag(), e);
207 throw new HomekitException("Cannot instantiate accessory implementation for accessory " + accessoryType);
212 * return HomeKit accessory types for a OH item based on meta data
214 * @param item OH item
215 * @param metadataRegistry meta data registry
216 * @return list of HomeKit accessory types and characteristics.
218 public static List<Entry<HomekitAccessoryType, HomekitCharacteristicType>> getAccessoryTypes(Item item,
219 MetadataRegistry metadataRegistry) {
220 final List<Entry<HomekitAccessoryType, HomekitCharacteristicType>> accessories = new ArrayList<>();
221 final @Nullable Metadata metadata = metadataRegistry.get(new MetadataKey(METADATA_KEY, item.getUID()));
222 boolean legacyMode = metadata == null;
223 String[] tags = !legacyMode ? metadata.getValue().split(",") : item.getTags().toArray(new String[0]); // fallback
224 for (String tag : tags) {
225 final String[] meta = tag.split("\\.");
226 Optional<HomekitAccessoryType> accessoryType = HomekitAccessoryType.valueOfTag(meta[0].trim());
227 if (accessoryType.isPresent()) { // it accessory, check for characteristic
228 HomekitAccessoryType type = accessoryType.get();
229 if ((legacyMode) && (type.equals(LIGHTBULB))) { // support old smart logic to convert Lighting to
230 // DimmableLighting or ColorfulLighting depending on
232 if (item instanceof ColorItem) {
233 type = OLD_COLORFUL_LIGHTBULB;
234 } else if (item instanceof DimmerItem) {
235 type = OLD_DIMMABLE_LIGHTBULB;
238 if (meta.length > 1) {
239 // it has characteristic as well
240 accessories.add(new SimpleEntry<>(type,
241 HomekitCharacteristicType.valueOfTag(meta[1].trim()).orElse(EMPTY)));
242 } else {// it has no characteristic
243 accessories.add(new SimpleEntry<>(type, EMPTY));
245 } else { // it is no accessory, so, maybe it is a characteristic
246 HomekitCharacteristicType.valueOfTag(meta[0].trim())
247 .ifPresent(c -> accessories.add(new SimpleEntry<>(DUMMY, c)));
253 public static @Nullable Map<String, Object> getItemConfiguration(Item item, MetadataRegistry metadataRegistry) {
254 final @Nullable Metadata metadata = metadataRegistry.get(new MetadataKey(METADATA_KEY, item.getUID()));
255 return metadata != null ? metadata.getConfiguration() : null;
259 * return list of HomeKit relevant groups linked to an accessory
261 * @param item OH item
262 * @param itemRegistry item registry
263 * @param metadataRegistry metadata registry
264 * @return list of relevant group items
266 public static List<GroupItem> getAccessoryGroups(Item item, ItemRegistry itemRegistry,
267 MetadataRegistry metadataRegistry) {
268 return item.getGroupNames().stream().flatMap(name -> {
269 final @Nullable Item groupItem = itemRegistry.get(name);
270 if ((groupItem instanceof GroupItem) && ((GroupItem) groupItem).getBaseItem() == null) {
271 return Stream.of((GroupItem) groupItem);
273 return Stream.empty();
275 }).filter(groupItem -> !getAccessoryTypes(groupItem, metadataRegistry).isEmpty()).collect(Collectors.toList());
279 * collect all mandatory characteristics for a given tagged item, e.g. collect all mandatory HomeKit items from a
282 * @param taggedItem HomeKit tagged item
283 * @param metadataRegistry meta data registry
284 * @return list of mandatory
286 private static List<HomekitTaggedItem> getMandatoryCharacteristics(HomekitTaggedItem taggedItem,
287 MetadataRegistry metadataRegistry) {
288 List<HomekitTaggedItem> collectedCharacteristics = new ArrayList<>();
289 if (taggedItem.isGroup()) {
290 for (Item item : ((GroupItem) taggedItem.getItem()).getAllMembers()) {
291 addMandatoryCharacteristics(taggedItem, collectedCharacteristics, item, metadataRegistry);
294 addMandatoryCharacteristics(taggedItem, collectedCharacteristics, taggedItem.getItem(), metadataRegistry);
296 logger.trace("Mandatory characteristics for item {} characteristics {}", taggedItem.getName(),
297 collectedCharacteristics);
298 return collectedCharacteristics;
302 * add mandatory HomeKit items for a given main item to a list of characteristics.
303 * Main item is use only to determine, which characteristics are mandatory.
304 * The characteristics are added to item.
305 * e.g. mainItem could be a group tagged as "thermostat" and item could be item linked to the group and marked as
308 * @param mainItem main item
309 * @param characteristics list of characteristics
310 * @param item current item
311 * @param metadataRegistry meta date registry
313 private static void addMandatoryCharacteristics(HomekitTaggedItem mainItem, List<HomekitTaggedItem> characteristics,
314 Item item, MetadataRegistry metadataRegistry) {
315 // get list of mandatory characteristics
316 HomekitCharacteristicType[] mandatoryCharacteristics = MANDATORY_CHARACTERISTICS
317 .get(mainItem.getAccessoryType());
318 if ((mandatoryCharacteristics == null) || (mandatoryCharacteristics.length == 0)) {
319 // no mandatory characteristics linked to accessory type of mainItem. we are done
322 // check whether we adding characteristic to the main item, and if yes, use existing item proxy.
323 // if we adding no to the main item (typical for groups), create new proxy item.
324 final HomekitOHItemProxy itemProxy = mainItem.getItem().equals(item) ? mainItem.getProxyItem()
325 : new HomekitOHItemProxy(item);
326 // an item can have several tags, e.g. "ActiveStatus, InUse". we iterate here over all his tags
327 for (Entry<HomekitAccessoryType, HomekitCharacteristicType> accessory : getAccessoryTypes(item,
329 // if the item has only accessory tag, e.g. TemperatureSensor,
330 // the we will link all mandatory characteristic to this item,
331 // e.g. we will link CurrentTemperature in case of TemperatureSensor.
332 if (isRootAccessory(accessory)) {
333 Arrays.stream(mandatoryCharacteristics)
334 .forEach(c -> characteristics.add(new HomekitTaggedItem(itemProxy, accessory.getKey(), c,
335 mainItem.isGroup() ? (GroupItem) mainItem.getItem() : null,
336 HomekitAccessoryFactory.getItemConfiguration(item, metadataRegistry))));
338 // item has characteristic tag on it, so, adding it as that characteristic.
340 // check whether it is a legacy characteristic, i.e. old tag was used, and replaced by a new one
341 final HomekitCharacteristicType characteristic = legacyCheck(accessory.getValue());
343 // check whether it is a mandatory characteristic. optional will be added later by another method.
344 if (isMandatoryCharacteristic(mainItem.getAccessoryType(), characteristic)) {
345 characteristics.add(new HomekitTaggedItem(itemProxy, accessory.getKey(), characteristic,
346 mainItem.isGroup() ? (GroupItem) mainItem.getItem() : null,
347 HomekitAccessoryFactory.getItemConfiguration(item, metadataRegistry)));
354 * add optional characteristic for given accessory.
356 * @param taggedItem main item
357 * @param accessory accessory
358 * @param metadataRegistry metadata registry
360 private static void addOptionalCharacteristics(HomekitTaggedItem taggedItem, AbstractHomekitAccessoryImpl accessory,
361 MetadataRegistry metadataRegistry) {
362 Map<HomekitCharacteristicType, GenericItem> characteristics = getOptionalCharacteristics(
363 accessory.getRootAccessory(), metadataRegistry);
364 Service service = accessory.getPrimaryService();
365 HashMap<String, HomekitOHItemProxy> proxyItems = new HashMap<>();
366 proxyItems.put(taggedItem.getItem().getUID(), taggedItem.getProxyItem());
367 // an accessory can have multiple optional characteristics. iterate over them.
368 characteristics.forEach((type, item) -> {
370 // check whether a proxyItem already exists, if not create one.
371 final HomekitOHItemProxy proxyItem = proxyItems.computeIfAbsent(item.getUID(),
372 k -> new HomekitOHItemProxy(item));
373 final HomekitTaggedItem optionalItem = new HomekitTaggedItem(proxyItem,
374 accessory.getRootAccessory().getAccessoryType(), type,
375 accessory.getRootAccessory().getRootDeviceGroupItem(),
376 getItemConfiguration(item, metadataRegistry));
377 final Characteristic characteristic = HomekitCharacteristicFactory.createCharacteristic(optionalItem,
378 accessory.getUpdater());
379 // find the corresponding add method at service and call it.
380 service.getClass().getMethod("addOptionalCharacteristic", characteristic.getClass()).invoke(service,
382 accessory.addCharacteristic(optionalItem);
383 } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | HomekitException e) {
384 logger.warn("Unsupported optional HomeKit characteristic: service type {}, characteristic type {}",
385 service.getType(), type.getTag());
391 * collect optional HomeKit characteristics for a OH item.
393 * @param taggedItem main OH item
394 * @param metadataRegistry OH metadata registry
395 * @return a map with characteristics and corresponding OH items
397 private static Map<HomekitCharacteristicType, GenericItem> getOptionalCharacteristics(HomekitTaggedItem taggedItem,
398 MetadataRegistry metadataRegistry) {
399 Map<HomekitCharacteristicType, GenericItem> characteristicItems = new HashMap<>();
400 if (taggedItem.isGroup()) {
401 GroupItem groupItem = (GroupItem) taggedItem.getItem();
402 groupItem.getMembers().forEach(item -> getAccessoryTypes(item, metadataRegistry).stream()
403 .filter(c -> !isRootAccessory(c))
404 .filter(c -> !isMandatoryCharacteristic(taggedItem.getAccessoryType(), legacyCheck(c.getValue())))
405 .forEach(characteristic -> characteristicItems.put(legacyCheck(characteristic.getValue()),
406 (GenericItem) item)));
408 getAccessoryTypes(taggedItem.getItem(), metadataRegistry).stream().filter(c -> !isRootAccessory(c))
409 .filter(c -> !isMandatoryCharacteristic(taggedItem.getAccessoryType(), legacyCheck(c.getValue())))
410 .forEach(characteristic -> characteristicItems.put(legacyCheck(characteristic.getValue()),
411 (GenericItem) taggedItem.getItem()));
412 final HomekitCharacteristicType[] implicitOptionalCharacteristics = IMPLICIT_OPTIONAL_CHARACTERISTICS
413 .get(taggedItem.getAccessoryType());
414 if (implicitOptionalCharacteristics != null) {
415 Arrays.stream(implicitOptionalCharacteristics)
416 .filter(c -> !isMandatoryCharacteristic(taggedItem.getAccessoryType(), c))
417 .forEach(characteristic -> characteristicItems.put(legacyCheck(characteristic),
418 (GenericItem) taggedItem.getItem()));
421 logger.trace("Optional characteristics for item {} characteristics {}", taggedItem.getName(),
422 characteristicItems);
423 return Collections.unmodifiableMap(characteristicItems);
427 * return true is characteristic is a mandatory characteristic for the accessory.
429 * @param accessory accessory
430 * @param characteristic characteristic
431 * @return true if characteristic is mandatory, false if not mandatory
433 private static boolean isMandatoryCharacteristic(HomekitAccessoryType accessory,
434 HomekitCharacteristicType characteristic) {
435 return MANDATORY_CHARACTERISTICS.containsKey(accessory)
436 && Arrays.asList(MANDATORY_CHARACTERISTICS.get(accessory)).contains(characteristic);
440 * check whether accessory is root accessory, i.e. without characteristic tag.
442 * @param accessory accessory
443 * @return true if accessory has not characteristic.
445 private static boolean isRootAccessory(Entry<HomekitAccessoryType, HomekitCharacteristicType> accessory) {
446 return ((accessory.getValue() == null) || (accessory.getValue() == EMPTY));
450 * check whether it is legacy characteristic and return new name in such case. otherwise return the input parameter
453 * @param characteristicType characteristic to check
454 * @return new characteristic type
456 private static HomekitCharacteristicType legacyCheck(HomekitCharacteristicType characteristicType) {
457 return LEGACY_CHARACTERISTICS_MAPPING.getOrDefault(characteristicType, characteristicType);