[homekit] add BasicFan accessory (#13564)
* [homekit] add BasicFan accessory This is Fan v1. It's a subset of FanV2, except that Home allows you to customize the icon to show a ceiling fan. Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
76c785947b
commit
108c48dda5
|
@ -747,6 +747,10 @@ Support for this is planned for the future release of openHAB HomeKit binding.
|
||||||
| | | RotationSpeed | Number, Dimmer | Fan rotation speed in % (1-100) |
|
| | | 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 |
|
| | | 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 |
|
| | | 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 |
|
| Thermostat | | | | A thermostat requires all mandatory characteristics defined below |
|
||||||
| | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step |
|
| | CurrentTemperature | | Number | Current temperature. supported configuration: minValue, maxValue, step |
|
||||||
| | TargetTemperature | | Number | Target temperature. supported configuration: minValue, maxValue, step |
|
| | TargetTemperature | | Number | Target temperature. supported configuration: minValue, maxValue, step |
|
||||||
|
|
|
@ -39,6 +39,7 @@ public enum HomekitAccessoryType {
|
||||||
SMOKE_SENSOR("SmokeSensor"),
|
SMOKE_SENSOR("SmokeSensor"),
|
||||||
CARBON_MONOXIDE_SENSOR("CarbonMonoxideSensor"),
|
CARBON_MONOXIDE_SENSOR("CarbonMonoxideSensor"),
|
||||||
CARBON_DIOXIDE_SENSOR("CarbonDioxideSensor"),
|
CARBON_DIOXIDE_SENSOR("CarbonDioxideSensor"),
|
||||||
|
BASIC_FAN("BasicFan"),
|
||||||
FAN("Fan"),
|
FAN("Fan"),
|
||||||
LOCK("Lock"),
|
LOCK("Lock"),
|
||||||
SECURITY_SYSTEM("SecuritySystem"),
|
SECURITY_SYSTEM("SecuritySystem"),
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class HomekitAccessoryFactory {
|
||||||
put(CARBON_MONOXIDE_SENSOR, new HomekitCharacteristicType[] { CARBON_MONOXIDE_DETECTED_STATE });
|
put(CARBON_MONOXIDE_SENSOR, new HomekitCharacteristicType[] { CARBON_MONOXIDE_DETECTED_STATE });
|
||||||
put(WINDOW_COVERING, new HomekitCharacteristicType[] { TARGET_POSITION, CURRENT_POSITION, POSITION_STATE });
|
put(WINDOW_COVERING, new HomekitCharacteristicType[] { TARGET_POSITION, CURRENT_POSITION, POSITION_STATE });
|
||||||
put(LIGHTBULB, new HomekitCharacteristicType[] { ON_STATE });
|
put(LIGHTBULB, new HomekitCharacteristicType[] { ON_STATE });
|
||||||
|
put(BASIC_FAN, new HomekitCharacteristicType[] { ON_STATE });
|
||||||
put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS });
|
put(FAN, new HomekitCharacteristicType[] { ACTIVE_STATUS });
|
||||||
put(LIGHT_SENSOR, new HomekitCharacteristicType[] { LIGHT_LEVEL });
|
put(LIGHT_SENSOR, new HomekitCharacteristicType[] { LIGHT_LEVEL });
|
||||||
put(TEMPERATURE_SENSOR, new HomekitCharacteristicType[] { CURRENT_TEMPERATURE });
|
put(TEMPERATURE_SENSOR, new HomekitCharacteristicType[] { CURRENT_TEMPERATURE });
|
||||||
|
@ -119,6 +120,7 @@ public class HomekitAccessoryFactory {
|
||||||
put(CARBON_MONOXIDE_SENSOR, HomekitCarbonMonoxideSensorImpl.class);
|
put(CARBON_MONOXIDE_SENSOR, HomekitCarbonMonoxideSensorImpl.class);
|
||||||
put(WINDOW_COVERING, HomekitWindowCoveringImpl.class);
|
put(WINDOW_COVERING, HomekitWindowCoveringImpl.class);
|
||||||
put(LIGHTBULB, HomekitLightbulbImpl.class);
|
put(LIGHTBULB, HomekitLightbulbImpl.class);
|
||||||
|
put(BASIC_FAN, HomekitBasicFanImpl.class);
|
||||||
put(FAN, HomekitFanImpl.class);
|
put(FAN, HomekitFanImpl.class);
|
||||||
put(LIGHT_SENSOR, HomekitLightSensorImpl.class);
|
put(LIGHT_SENSOR, HomekitLightSensorImpl.class);
|
||||||
put(TEMPERATURE_SENSOR, HomekitTemperatureSensorImpl.class);
|
put(TEMPERATURE_SENSOR, HomekitTemperatureSensorImpl.class);
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue