[bondhome] Add raw speed channel (#14155)

* [bondhome] add raw speed channel

* Add a channel for the raw speed value from the bond api

Signed-off-by: Keith T. Garner <kgarner@kgarner.com>
This commit is contained in:
Keith T. Garner 2023-01-12 00:42:15 -06:00 committed by GitHub
parent f16f524877
commit 03a67d25b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 1 deletions

View File

@ -59,6 +59,7 @@ public class BondHomeBindingConstants {
public static final String CHANNEL_GROUP_FAN = "fan"; public static final String CHANNEL_GROUP_FAN = "fan";
public static final String CHANNEL_FAN_POWER = CHANNEL_GROUP_FAN + "#power"; public static final String CHANNEL_FAN_POWER = CHANNEL_GROUP_FAN + "#power";
public static final String CHANNEL_FAN_SPEED = CHANNEL_GROUP_FAN + "#speed"; public static final String CHANNEL_FAN_SPEED = CHANNEL_GROUP_FAN + "#speed";
public static final String CHANNEL_RAW_FAN_SPEED = CHANNEL_GROUP_FAN + "#rawSpeed";
public static final String CHANNEL_FAN_BREEZE_STATE = CHANNEL_GROUP_FAN + "#breezeState"; public static final String CHANNEL_FAN_BREEZE_STATE = CHANNEL_GROUP_FAN + "#breezeState";
public static final String CHANNEL_FAN_BREEZE_MEAN = CHANNEL_GROUP_FAN + "#breezeMean"; public static final String CHANNEL_FAN_BREEZE_MEAN = CHANNEL_GROUP_FAN + "#breezeMean";
public static final String CHANNEL_FAN_BREEZE_VAR = CHANNEL_GROUP_FAN + "#breezeVariability"; public static final String CHANNEL_FAN_BREEZE_VAR = CHANNEL_GROUP_FAN + "#breezeVariability";

View File

@ -205,6 +205,27 @@ public class BondDeviceHandler extends BaseThingHandler {
} }
break; break;
case CHANNEL_RAW_FAN_SPEED:
if (command instanceof DecimalType) {
value = ((DecimalType) command).intValue();
BondDeviceProperties devProperties = this.deviceProperties;
if (devProperties != null) {
if (value < 1) {
// Interpret any 0 or less value as a request to turn off
action = BondDeviceAction.TURN_OFF;
value = null;
} else {
action = BondDeviceAction.SET_SPEED;
value = Math.min(value, devProperties.maxSpeed);
}
logger.trace("Fan raw speed command with speed set as {}, action as {}", value, action);
api.executeDeviceAction(deviceId, action, value);
}
} else {
logger.info("Unsupported command on raw fan speed channel");
}
break;
case CHANNEL_FAN_BREEZE_STATE: case CHANNEL_FAN_BREEZE_STATE:
logger.trace("Fan enable/disable breeze command"); logger.trace("Fan enable/disable breeze command");
api.executeDeviceAction(deviceId, api.executeDeviceAction(deviceId,
@ -548,6 +569,7 @@ public class BondDeviceHandler extends BaseThingHandler {
logger.trace("Deleting channels based on the available actions"); logger.trace("Deleting channels based on the available actions");
// Get the thing to edit // Get the thing to edit
ThingBuilder thingBuilder = editThing(); ThingBuilder thingBuilder = editThing();
final BondDevice devInfo = this.deviceInfo;
// Now, look at the whole list of possible channels // Now, look at the whole list of possible channels
List<Channel> possibleChannels = this.getThing().getChannels(); List<Channel> possibleChannels = this.getThing().getChannels();
@ -561,10 +583,14 @@ public class BondDeviceHandler extends BaseThingHandler {
} }
} }
// Remove power channels if we have a dimmer channel for them; // Remove power channels if we have a dimmer channel for them;
// the dimmer channel already covers the power case // the dimmer channel already covers the power case.
// Add the raw channel for advanced users if we're a ceiling fan.
if (availableChannelIds.contains(CHANNEL_FAN_SPEED)) { if (availableChannelIds.contains(CHANNEL_FAN_SPEED)) {
availableChannelIds.remove(CHANNEL_POWER); availableChannelIds.remove(CHANNEL_POWER);
availableChannelIds.remove(CHANNEL_FAN_POWER); availableChannelIds.remove(CHANNEL_FAN_POWER);
if (devInfo != null && devInfo.type == BondDeviceType.CEILING_FAN) {
availableChannelIds.add(CHANNEL_RAW_FAN_SPEED);
}
} }
if (availableChannelIds.contains(CHANNEL_LIGHT_BRIGHTNESS)) { if (availableChannelIds.contains(CHANNEL_LIGHT_BRIGHTNESS)) {
availableChannelIds.remove(CHANNEL_LIGHT_POWER); availableChannelIds.remove(CHANNEL_LIGHT_POWER);
@ -631,6 +657,7 @@ public class BondDeviceHandler extends BaseThingHandler {
logger.info("Unable to convert fan speed to a percent for {}!", this.getThing().getLabel()); logger.info("Unable to convert fan speed to a percent for {}!", this.getThing().getLabel());
} }
updateState(CHANNEL_FAN_SPEED, formPercentType(fanOn, value)); updateState(CHANNEL_FAN_SPEED, formPercentType(fanOn, value));
updateState(CHANNEL_RAW_FAN_SPEED, fanOn ? new DecimalType(updateState.speed) : DecimalType.ZERO);
} }
updateState(CHANNEL_FAN_BREEZE_STATE, updateState.breeze[0] == 0 ? OnOffType.OFF : OnOffType.ON); updateState(CHANNEL_FAN_BREEZE_STATE, updateState.breeze[0] == 0 ? OnOffType.OFF : OnOffType.ON);
updateState(CHANNEL_FAN_BREEZE_MEAN, new PercentType(updateState.breeze[1])); updateState(CHANNEL_FAN_BREEZE_MEAN, new PercentType(updateState.breeze[1]));

View File

@ -71,6 +71,8 @@ channel-type.bondhome.enableChannelType.label = Enable Up or Down Light
channel-type.bondhome.enableChannelType.description = Enables or disables the up or down light of the ceiling fan. The light must also be on to turn on the up light. channel-type.bondhome.enableChannelType.description = Enables or disables the up or down light of the ceiling fan. The light must also be on to turn on the up light.
channel-type.bondhome.fanSpeedChannelType.label = Fan Speed channel-type.bondhome.fanSpeedChannelType.label = Fan Speed
channel-type.bondhome.fanSpeedChannelType.description = Sets fan speed channel-type.bondhome.fanSpeedChannelType.description = Sets fan speed
channel-type.bondhome.rawFanSpeedChannelType.label = Raw Fan Speed
channel-type.bondhome.rawFanSpeedChannelType.description = Sets fan speed using raw Bond values
channel-type.bondhome.flameChannelType.label = Flame Level channel-type.bondhome.flameChannelType.label = Flame Level
channel-type.bondhome.flameChannelType.description = Turns on or adjust the flame level channel-type.bondhome.flameChannelType.description = Turns on or adjust the flame level
channel-type.bondhome.fpFanSpeedChannelType.label = Fireplace Fan Speed channel-type.bondhome.fpFanSpeedChannelType.label = Fireplace Fan Speed

View File

@ -18,6 +18,7 @@
<label>Ceiling Fan</label> <label>Ceiling Fan</label>
<channels> <channels>
<channel id="speed" typeId="fanSpeedChannelType"/> <channel id="speed" typeId="fanSpeedChannelType"/>
<channel id="rawSpeed" typeId="rawFanSpeedChannelType"/>
<channel id="breezeState" typeId="breezeStateChannelType"/> <channel id="breezeState" typeId="breezeStateChannelType"/>
<channel id="breezeMean" typeId="breezeMeanChannelType"/> <channel id="breezeMean" typeId="breezeMeanChannelType"/>
<channel id="breezeVariability" typeId="breezeVariabilityChannelType"/> <channel id="breezeVariability" typeId="breezeVariabilityChannelType"/>

View File

@ -36,6 +36,13 @@
<category>Heating</category> <category>Heating</category>
</channel-type> </channel-type>
<channel-type id="rawFanSpeedChannelType" advanced="true">
<item-type>Number</item-type>
<label>Raw Fan Speed</label>
<description>Sets fan speed using raw Bond values</description>
<category>Heating</category>
</channel-type>
<channel-type id="breezeStateChannelType"> <channel-type id="breezeStateChannelType">
<item-type>Switch</item-type> <item-type>Switch</item-type>
<label>Breeze Mode</label> <label>Breeze Mode</label>