| | | RotationSpeed | Number, Dimmer | Fan rotation speed in % (1-100) |
| | | SwingMode | Number, Switch | Swing mode. values: 0/OFF=SWING DISABLED, 1/ON=SWING ENABLED. Flag [inverted=true] swaps the default mapping |
| | | LockControl | Number, Switch | Status of physical control lock. values: 0/OFF=CONTROL LOCK DISABLED, 1/ON=CONTROL LOCK ENABLED.Flag [inverted=true] swaps the default mapping |
+| BasicFan | | | | Fan. A BasicFan is a subset of Fan, but the Home app allows you to customize the icon of the accessory to show a ceiling fan. |
+| | OnState | | Switch, Dimmer | Accessory current working status. A value of "ON"/"OPEN" indicates that the accessory is active and is functioning without any errors. |
+| | | RotationDirection | Number, Switch | Rotation direction. values: 0/OFF=CLOCKWISE, 1/ON=COUNTER CLOCKWISE. Flag [inverted=true] swaps the default mapping |
+| | | RotationSpeed | Number, Dimmer | Fan rotation speed in % (1-100) |
| Thermostat | | | | A thermostat requires all mandatory characteristics defined below |
| | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step |
| | TargetTemperature | | Number | Target temperature. supported configuration: minValue, maxValue, step |
SMOKE_SENSOR("SmokeSensor"),
CARBON_MONOXIDE_SENSOR("CarbonMonoxideSensor"),
CARBON_DIOXIDE_SENSOR("CarbonDioxideSensor"),
+ BASIC_FAN("BasicFan"),
FAN("Fan"),
LOCK("Lock"),
SECURITY_SYSTEM("SecuritySystem"),
put(CARBON_MONOXIDE_SENSOR, new HomekitCharacteristicType[] { CARBON_MONOXIDE_DETECTED_STATE });
put(WINDOW_COVERING, new HomekitCharacteristicType[] { TARGET_POSITION, CURRENT_POSITION, POSITION_STATE });
put(LIGHTBULB, new HomekitCharacteristicType[] { ON_STATE });
+ put(BASIC_FAN, new HomekitCharacteristicType[] { ON_STATE });
put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS });
put(LIGHT_SENSOR, new HomekitCharacteristicType[] { LIGHT_LEVEL });
put(TEMPERATURE_SENSOR, new HomekitCharacteristicType[] { CURRENT_TEMPERATURE });
put(CARBON_MONOXIDE_SENSOR, HomekitCarbonMonoxideSensorImpl.class);
put(WINDOW_COVERING, HomekitWindowCoveringImpl.class);
put(LIGHTBULB, HomekitLightbulbImpl.class);
+ put(BASIC_FAN, HomekitBasicFanImpl.class);
put(FAN, HomekitFanImpl.class);
put(LIGHT_SENSOR, HomekitLightSensorImpl.class);
put(TEMPERATURE_SENSOR, HomekitTemperatureSensorImpl.class);
--- /dev/null
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.io.homekit.internal.accessories;
+
+import static org.openhab.io.homekit.internal.HomekitCharacteristicType.ON_STATE;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.io.homekit.internal.HomekitAccessoryUpdater;
+import org.openhab.io.homekit.internal.HomekitSettings;
+import org.openhab.io.homekit.internal.HomekitTaggedItem;
+
+import io.github.hapjava.accessories.BasicFanAccessory;
+import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
+import io.github.hapjava.services.impl.BasicFanService;
+
+/**
+ * Implements Fan using an Item that provides an On/Off state
+ *
+ * @author Cody Cutrer - Initial contribution
+ */
+@NonNullByDefault({})
+class HomekitBasicFanImpl extends AbstractHomekitAccessoryImpl implements BasicFanAccessory {
+ private final BooleanItemReader onReader;
+
+ public HomekitBasicFanImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
+ HomekitAccessoryUpdater updater, HomekitSettings settings) throws IncompleteAccessoryException {
+ super(taggedItem, mandatoryCharacteristics, updater, settings);
+ onReader = createBooleanReader(ON_STATE);
+ this.getServices().add(new BasicFanService(this));
+ }
+
+ @Override
+ public CompletableFuture<Boolean> isOn() {
+ return CompletableFuture.completedFuture(onReader.getValue());
+ }
+
+ @Override
+ public CompletableFuture<Void> setOn(boolean state) {
+ onReader.setValue(state);
+ return CompletableFuture.completedFuture(null);
+ }
+
+ @Override
+ public void subscribeOn(HomekitCharacteristicChangeCallback callback) {
+ subscribe(ON_STATE, callback);
+ }
+
+ @Override
+ public void unsubscribeOn() {
+ unsubscribe(ON_STATE);
+ }
+}