Add shade RF RSSI for hub/repeater (#13096)

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2022-07-25 12:56:03 +02:00 committed by GitHub
parent dcc9190d2e
commit 9ec6f7d12e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 3 deletions

View File

@ -64,7 +64,6 @@ PowerView app. However, the configuration parameters are described below.
#### Thing Configuration for PowerView Repeaters
| Configuration Parameter | Description |
|-------------------------|-------------|
| id | The ID of the PowerView repeater in the app. Must be an integer. |
@ -100,6 +99,10 @@ All of these channels appear in the binding, but only those which have a physica
| batteryLevel | Number | Battery level (10% = low, 50% = medium, 100% = high)
| batteryVoltage | Number:ElectricPotential | Battery voltage reported by the shade. |
| signalStrength | Number | Signal strength (0 for no or unknown signal, 1 for weak, 2 for average, 3 for good or 4 for excellent) |
| hubRssi | Number:Power | Received Signal Strength Indicator for Hub |
| repeaterRssi | Number:Power | Received Signal Strength Indicator for Repeater |
Please note that RSSI values will only be updated upon manual request by a `REFRESH` command (e.g. in a rule).
### Channels for Repeaters (Thing type `repeater`)
@ -210,6 +213,8 @@ For single shades the refresh takes the item's channel into consideration:
| batteryLevel | Battery |
| batteryVoltage | Battery |
| signalStrength | Survey |
| hubRssi | Survey |
| repeaterRssi | Survey |
## Full Example

View File

@ -46,6 +46,8 @@ public class HDPowerViewBindingConstants {
public static final String CHANNEL_SHADE_BATTERY_LEVEL = "batteryLevel";
public static final String CHANNEL_SHADE_BATTERY_VOLTAGE = "batteryVoltage";
public static final String CHANNEL_SHADE_SIGNAL_STRENGTH = "signalStrength";
public static final String CHANNEL_SHADE_HUB_RSSI = "hubRssi";
public static final String CHANNEL_SHADE_REPEATER_RSSI = "repeaterRssi";
public static final String CHANNEL_REPEATER_COLOR = "color";
public static final String CHANNEL_REPEATER_BRIGHTNESS = "brightness";

View File

@ -150,6 +150,8 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
requestRefreshShadeBatteryLevel();
break;
case CHANNEL_SHADE_SIGNAL_STRENGTH:
case CHANNEL_SHADE_HUB_RSSI:
case CHANNEL_SHADE_REPEATER_RSSI:
requestRefreshShadeSurvey();
break;
}
@ -534,15 +536,32 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
surveyData.forEach(data -> joiner.add(data.toString()));
logger.debug("Survey response for shade {}: {}", shadeId, joiner.toString());
}
int hubRssi = Integer.MAX_VALUE;
int repeaterRssi = Integer.MAX_VALUE;
for (SurveyData survey : surveyData) {
if (survey.neighborId == 0) {
hubRssi = survey.rssi;
} else {
repeaterRssi = survey.rssi;
}
}
updateState(CHANNEL_SHADE_HUB_RSSI, hubRssi == Integer.MAX_VALUE ? UnDefType.UNDEF
: new QuantityType<>(hubRssi, Units.DECIBEL_MILLIWATTS));
updateState(CHANNEL_SHADE_REPEATER_RSSI, repeaterRssi == Integer.MAX_VALUE ? UnDefType.UNDEF
: new QuantityType<>(repeaterRssi, Units.DECIBEL_MILLIWATTS));
shadeData = webTargets.getShade(shadeId);
updateSignalStrengthState(shadeData.signalStrength);
} else {
logger.info("No data from shade {} survey", shadeId);
/*
* Setting channel to UNDEF here would be reverted on next poll, since
* signal strength is part of shade response. So leaving current value,
* Setting signal strength channel to UNDEF here would be reverted on next poll,
* since signal strength is part of shade response. So leaving current value,
* even though refreshing the value failed.
*/
updateState(CHANNEL_SHADE_HUB_RSSI, UnDefType.UNDEF);
updateState(CHANNEL_SHADE_REPEATER_RSSI, UnDefType.UNDEF);
}
break;
case BATTERY_LEVEL:
@ -559,6 +578,12 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
} else {
logger.warn("Bridge returned a bad JSON response: {} -> {}", e.getMessage(), cause.getMessage());
}
// Survey calls are unreliable and often returns "{}" as payload. For repeater RSSI tracking to be useful,
// we need to reset channels also in this case.
if (kind == RefreshKind.SURVEY) {
updateState(CHANNEL_SHADE_HUB_RSSI, UnDefType.UNDEF);
updateState(CHANNEL_SHADE_REPEATER_RSSI, UnDefType.UNDEF);
}
} catch (HubMaintenanceException e) {
// exceptions are logged in HDPowerViewWebTargets
} catch (HubShadeTimeoutException e) {

View File

@ -13,6 +13,10 @@ thing-type.hdpowerview.repeater.channel.brightness.description = Controls the br
thing-type.hdpowerview.repeater.channel.color.description = Controls the color of the LED ring
thing-type.hdpowerview.shade.label = PowerView Shade
thing-type.hdpowerview.shade.description = Hunter Douglas (Luxaflex) PowerView Shade
thing-type.hdpowerview.shade.channel.hubRssi.label = Hub RSSI
thing-type.hdpowerview.shade.channel.hubRssi.description = Received Signal Strength Indicator for Hub
thing-type.hdpowerview.shade.channel.repeaterRssi.label = Repeater RSSI
thing-type.hdpowerview.shade.channel.repeaterRssi.description = Received Signal Strength Indicator for Repeater
thing-type.hdpowerview.shade.channel.secondary.label = Secondary Position
thing-type.hdpowerview.shade.channel.secondary.description = The secondary vertical position (on top-down/bottom-up shades)
@ -47,6 +51,8 @@ channel-type.hdpowerview.repeater-blinking-enabled.description = Blink during co
channel-type.hdpowerview.repeater-identify.label = Identify
channel-type.hdpowerview.repeater-identify.description = Flash repeater to identify
channel-type.hdpowerview.repeater-identify.command.option.IDENTIFY = Identify
channel-type.hdpowerview.rssi.label = RSSI
channel-type.hdpowerview.rssi.description = Received Signal Strength Indicator
channel-type.hdpowerview.scene-activate.label = Activate
channel-type.hdpowerview.scene-group-activate.label = Activate
channel-type.hdpowerview.shade-command.label = Command

View File

@ -51,6 +51,14 @@
<state pattern="%.1f %unit%" readOnly="true"/>
</channel-type>
<channel-type id="rssi" advanced="true">
<item-type>Number:Power</item-type>
<label>RSSI</label>
<description>Received Signal Strength Indicator</description>
<category>QualityOfService</category>
<state readOnly="true" pattern="%d %unit%"></state>
</channel-type>
<channel-type id="repeater-identify">
<item-type>String</item-type>
<label>Identify</label>

View File

@ -23,6 +23,14 @@
<channel id="batteryLevel" typeId="system.battery-level"/>
<channel id="batteryVoltage" typeId="battery-voltage"/>
<channel id="signalStrength" typeId="system.signal-strength"/>
<channel id="hubRssi" typeId="rssi">
<label>Hub RSSI</label>
<description>Received Signal Strength Indicator for Hub</description>
</channel>
<channel id="repeaterRssi" typeId="rssi">
<label>Repeater RSSI</label>
<description>Received Signal Strength Indicator for Repeater</description>
</channel>
</channels>
<properties>