Skip to content

Commit

Permalink
[powermax] New channel of type Contact to show the zone arm status (o…
Browse files Browse the repository at this point in the history
…penhab#9192)

Allow using lock icon from the classic iconset
Allow displaying the "Locks" badge in MainUI
  • Loading branch information
lolodomo committed Dec 2, 2020
1 parent b18b5ea commit 9c5cad1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
Expand Up @@ -59,6 +59,7 @@ public class PowermaxBindingConstants {
public static final String LAST_TRIP = "last_trip";
public static final String BYPASSED = "bypassed";
public static final String ARMED = "armed";
public static final String LOCKED = "locked";
public static final String LOW_BATTERY = "low_battery";
public static final String PGM_STATUS = "pgm_status";
public static final String X10_STATUS = "x10_status";
Expand Down
Expand Up @@ -558,20 +558,10 @@ private synchronized void updateChannelsFromAlarmState(String channel, PowermaxS
PowermaxThingHandler handler = (PowermaxThingHandler) thing.getHandler();
if (handler != null) {
if (thing.getThingTypeUID().equals(THING_TYPE_ZONE)) {
if ((channel == null) || channel.equals(TRIPPED)) {
handler.updateChannelFromAlarmState(TRIPPED, state);
}
if ((channel == null) || channel.equals(LAST_TRIP)) {
handler.updateChannelFromAlarmState(LAST_TRIP, state);
}
if ((channel == null) || channel.equals(BYPASSED)) {
handler.updateChannelFromAlarmState(BYPASSED, state);
}
if ((channel == null) || channel.equals(ARMED)) {
handler.updateChannelFromAlarmState(ARMED, state);
}
if ((channel == null) || channel.equals(LOW_BATTERY)) {
handler.updateChannelFromAlarmState(LOW_BATTERY, state);
for (String channelId : List.of(TRIPPED, LAST_TRIP, BYPASSED, ARMED, LOCKED, LOW_BATTERY)) {
if ((channel == null) || channel.equals(channelId)) {
handler.updateChannelFromAlarmState(channelId, state);
}
}
} else if (thing.getThingTypeUID().equals(THING_TYPE_X10)) {
if ((channel == null) || channel.equals(X10_STATUS)) {
Expand Down
Expand Up @@ -191,6 +191,8 @@ public void updateChannelFromAlarmState(String channel, PowermaxState state) {
updateState(BYPASSED, state.isSensorBypassed(num) ? OnOffType.ON : OnOffType.OFF);
} else if (channel.equals(ARMED) && (state.isSensorArmed(num) != null)) {
updateState(ARMED, state.isSensorArmed(num) ? OnOffType.ON : OnOffType.OFF);
} else if (channel.equals(LOCKED) && (state.isSensorArmed(num) != null)) {
updateState(LOCKED, state.isSensorArmed(num) ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
} else if (channel.equals(LOW_BATTERY) && (state.isSensorLowBattery(num) != null)) {
updateState(LOW_BATTERY, state.isSensorLowBattery(num) ? OnOffType.ON : OnOffType.OFF);
}
Expand Down
Expand Up @@ -109,11 +109,18 @@

<channel-type id="armed">
<item-type>Switch</item-type>
<label>Zone Armed</label>
<label>Zone Armed (Switch)</label>
<description>Whether or not the zone is armed</description>
<state readOnly="true"></state>
</channel-type>

<channel-type id="locked">
<item-type>Contact</item-type>
<label>Zone Armed (Contact)</label>
<description>Whether or not the zone is armed (CLOSED when armed)</description>
<state readOnly="true"></state>
</channel-type>

<channel-type id="pgm_status" advanced="true">
<item-type>Switch</item-type>
<label>PGM Status</label>
Expand Down
Expand Up @@ -17,6 +17,7 @@
<channels>
<channel id="tripped" typeId="tripped"/>
<channel id="armed" typeId="armed"/>
<channel id="locked" typeId="locked"/>
<channel id="last_trip" typeId="last_trip"/>
<channel id="low_battery" typeId="system.low-battery"/>
<channel id="bypassed" typeId="bypassed"/>
Expand Down

0 comments on commit 9c5cad1

Please sign in to comment.