[paradoxalarm] Implement detailed partition state (#14618)
* Implement partition detailed state --------- Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
This commit is contained in:
parent
b4f367cfd7
commit
18ae9d46ec
@ -76,7 +76,8 @@ Currently binding supports the following panels: EVO192, EVO48(not tested), EVO9
|
|||||||
| Channel | Type | Description |
|
| Channel | Type | Description |
|
||||||
|--------------------------|---------|-----------------------------------------------------------------------------------------------|
|
|--------------------------|---------|-----------------------------------------------------------------------------------------------|
|
||||||
| partitionLabel | String | Label of partition inside Paradox configuration |
|
| partitionLabel | String | Label of partition inside Paradox configuration |
|
||||||
| state | String |State of partition (armed, disarmed, in alarm) |
|
| state | String | Calculated overall state of the partition (Armed, Disarmed, In Alarm) |
|
||||||
|
| detailedState | String | Calculated detailed state of the partition based on partition state bits (see below table for possible values) |
|
||||||
| additionalState | String | This used to be a channel where all different states were consolidated as semi-colon separated string. With implementation of each state as channel additional states should be no longer used. (deprecated channel) |
|
| additionalState | String | This used to be a channel where all different states were consolidated as semi-colon separated string. With implementation of each state as channel additional states should be no longer used. (deprecated channel) |
|
||||||
| readyToArm | Switch | Partition is Ready to arm |
|
| readyToArm | Switch | Partition is Ready to arm |
|
||||||
| inExitDelay | Switch | Partition is in Exit delay |
|
| inExitDelay | Switch | Partition is in Exit delay |
|
||||||
@ -95,6 +96,13 @@ Currently binding supports the following panels: EVO192, EVO48(not tested), EVO9
|
|||||||
| allZonesClosed | Contact | All zones in partition are currently closed |
|
| allZonesClosed | Contact | All zones in partition are currently closed |
|
||||||
| command | String | Command to be send to partition. Can be (ARM, DISARM, FORCE_ARM, INSTANT_ARM, STAY_ARM, BEEP) |
|
| command | String | Command to be send to partition. Can be (ARM, DISARM, FORCE_ARM, INSTANT_ARM, STAY_ARM, BEEP) |
|
||||||
|
|
||||||
|
### Partition detailed state possible values:
|
||||||
|
| Overall state value | Detailed state value (depending on the sub-state) |
|
||||||
|
|--------------------------|----------------------------------------------------------------------------------------------|
|
||||||
|
| InAlarm | Silent Alarm, Audible Alarm, Fire Alarm, In Alarm (if none of the first three) |
|
||||||
|
| Armed | Away Armed, Stay Armed, NoEntry Armed, Armed (if none of the first three) |
|
||||||
|
| Disarmed | Disarmed |
|
||||||
|
|
||||||
### Zone channels:
|
### Zone channels:
|
||||||
|
|
||||||
| Channel | Type | Description |
|
| Channel | Type | Description |
|
||||||
|
|||||||
@ -69,6 +69,7 @@ public class ParadoxAlarmBindingConstants {
|
|||||||
|
|
||||||
public static final String PARTITION_LABEL_CHANNEL_UID = "label";
|
public static final String PARTITION_LABEL_CHANNEL_UID = "label";
|
||||||
public static final String PARTITION_STATE_CHANNEL_UID = "state";
|
public static final String PARTITION_STATE_CHANNEL_UID = "state";
|
||||||
|
public static final String PARTITION_DETAILED_STATE_CHANNEL_UID = "detailedState";
|
||||||
@Deprecated // After implementation of channels for every possible state, the summarized additional states is no
|
@Deprecated // After implementation of channels for every possible state, the summarized additional states is no
|
||||||
// longer needed. We'll keep it for backward compatibility
|
// longer needed. We'll keep it for backward compatibility
|
||||||
public static final String PARTITION_ADDITIONAL_STATES_CHANNEL_UID = "additionalStates";
|
public static final String PARTITION_ADDITIONAL_STATES_CHANNEL_UID = "additionalStates";
|
||||||
|
|||||||
@ -48,6 +48,7 @@ public class ParadoxPartitionHandler extends EntityBaseHandler {
|
|||||||
if (partition != null) {
|
if (partition != null) {
|
||||||
updateState(PARTITION_LABEL_CHANNEL_UID, new StringType(partition.getLabel()));
|
updateState(PARTITION_LABEL_CHANNEL_UID, new StringType(partition.getLabel()));
|
||||||
updateState(PARTITION_STATE_CHANNEL_UID, new StringType(partition.getState().getMainState()));
|
updateState(PARTITION_STATE_CHANNEL_UID, new StringType(partition.getState().getMainState()));
|
||||||
|
updateState(PARTITION_DETAILED_STATE_CHANNEL_UID, new StringType(partition.getState().getDetailedState()));
|
||||||
updateState(PARTITION_ADDITIONAL_STATES_CHANNEL_UID,
|
updateState(PARTITION_ADDITIONAL_STATES_CHANNEL_UID,
|
||||||
new StringType("Deprecated field. Use direct channels instead"));
|
new StringType("Deprecated field. Use direct channels instead"));
|
||||||
updateState(PARTITION_READY_TO_ARM_CHANNEL_UID, booleanToSwitchState(partition.getState().isReadyToArm()));
|
updateState(PARTITION_READY_TO_ARM_CHANNEL_UID, booleanToSwitchState(partition.getState().isReadyToArm()));
|
||||||
|
|||||||
@ -40,7 +40,11 @@ public class Partition extends Entity implements Commandable {
|
|||||||
|
|
||||||
public Partition setState(PartitionState state) {
|
public Partition setState(PartitionState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
logger.debug("Partition {}:\t{}", getLabel(), getState().getMainState());
|
logger.debug("Partition {} main state:\t{}", getLabel(), getState().getMainState());
|
||||||
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("Partition {} detailed state:\t{}", getLabel(), getState().getDetailedState());
|
||||||
|
logger.trace("Partition {} full state dump:\t{}", getLabel(), getState());
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,16 @@ package org.openhab.binding.paradoxalarm.internal.model;
|
|||||||
*/
|
*/
|
||||||
public class PartitionState {
|
public class PartitionState {
|
||||||
|
|
||||||
|
private static final String ARMED = "Armed";
|
||||||
|
private static final String DISARMED = "Disarmed";
|
||||||
|
private static final String IN_ALARM = "InAlarm";
|
||||||
|
|
||||||
|
private static final String ARMED_IN_NO_ENTRY = "NoEntry Armed";
|
||||||
|
private static final String ARMED_IN_STAY = "Stay Armed";
|
||||||
|
private static final String ARMED_IN_AWAY = "Away Armed";
|
||||||
|
private static final String FIRE_ALARM = "Fire Alarm";
|
||||||
|
private static final String AUDIBLE_ALARM = "Audible Alarm";
|
||||||
|
private static final String SILENT_ALARM = "Silent Alarm";
|
||||||
private boolean isArmed;
|
private boolean isArmed;
|
||||||
private boolean isArmedInAway;
|
private boolean isArmedInAway;
|
||||||
private boolean isArmedInStay;
|
private boolean isArmedInStay;
|
||||||
@ -47,13 +57,37 @@ public class PartitionState {
|
|||||||
private boolean areAllZoneclosed;
|
private boolean areAllZoneclosed;
|
||||||
|
|
||||||
public String getMainState() {
|
public String getMainState() {
|
||||||
if (isInAlarm) {
|
if (isInAlarm || isInSilentAlarm || isInAudibleAlarm || isInFireAlarm) {
|
||||||
return "InAlarm";
|
return IN_ALARM;
|
||||||
} else {
|
} else {
|
||||||
return isArmed || isArmedInAway || isArmedInStay || isArmedInNoEntry ? "Armed" : "Disarmed";
|
return isArmed || isArmedInAway || isArmedInStay || isArmedInNoEntry ? ARMED : DISARMED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDetailedState() {
|
||||||
|
if (isInAlarm) {
|
||||||
|
if (isInSilentAlarm) {
|
||||||
|
return SILENT_ALARM;
|
||||||
|
} else if (isInAudibleAlarm) {
|
||||||
|
return AUDIBLE_ALARM;
|
||||||
|
} else if (isInFireAlarm) {
|
||||||
|
return FIRE_ALARM;
|
||||||
|
}
|
||||||
|
return IN_ALARM;
|
||||||
|
} else if (isArmed) {
|
||||||
|
if (isArmedInAway) {
|
||||||
|
return ARMED_IN_AWAY;
|
||||||
|
} else if (isArmedInStay) {
|
||||||
|
return ARMED_IN_STAY;
|
||||||
|
} else if (isArmedInNoEntry) {
|
||||||
|
return ARMED_IN_NO_ENTRY;
|
||||||
|
}
|
||||||
|
return ARMED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DISARMED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PartitionState [isArmed=" + isArmed + ", isArmedInAway=" + isArmedInAway + ", isArmedInStay="
|
return "PartitionState [isArmed=" + isArmed + ", isArmedInAway=" + isArmedInAway + ", isArmedInStay="
|
||||||
|
|||||||
@ -69,6 +69,8 @@ channel-type.paradoxalarm.command.state.option.BYPASS = Bypass
|
|||||||
channel-type.paradoxalarm.command.state.option.CLEAR_BYPASS = Clear Bypass
|
channel-type.paradoxalarm.command.state.option.CLEAR_BYPASS = Clear Bypass
|
||||||
channel-type.paradoxalarm.communicationState.label = Bridge Communication State
|
channel-type.paradoxalarm.communicationState.label = Bridge Communication State
|
||||||
channel-type.paradoxalarm.communicationState.description = Status of connection to Paradox system
|
channel-type.paradoxalarm.communicationState.description = Status of connection to Paradox system
|
||||||
|
channel-type.paradoxalarm.detailedState.label = Detailed Partition State
|
||||||
|
channel-type.paradoxalarm.detailedState.description = The detailed state of partition (contains sub-states like Stay in Armed, Armed no entry, etc)
|
||||||
channel-type.paradoxalarm.forceReady.label = Partition Is Force Ready
|
channel-type.paradoxalarm.forceReady.label = Partition Is Force Ready
|
||||||
channel-type.paradoxalarm.forceReady.description = Partition is Force Ready
|
channel-type.paradoxalarm.forceReady.description = Partition is Force Ready
|
||||||
channel-type.paradoxalarm.generatedAlarm.label = Generated an Alarm
|
channel-type.paradoxalarm.generatedAlarm.label = Generated an Alarm
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
<channels>
|
<channels>
|
||||||
<channel id="label" typeId="partitionLabel"/>
|
<channel id="label" typeId="partitionLabel"/>
|
||||||
<channel id="state" typeId="state"/>
|
<channel id="state" typeId="state"/>
|
||||||
|
<channel id="detailedState" typeId="detailedState"/>
|
||||||
<channel id="additionalStates" typeId="additionalState"/>
|
<channel id="additionalStates" typeId="additionalState"/>
|
||||||
<channel id="readyToArm" typeId="readyToArm"/>
|
<channel id="readyToArm" typeId="readyToArm"/>
|
||||||
<channel id="inExitDelay" typeId="inExitDelay"/>
|
<channel id="inExitDelay" typeId="inExitDelay"/>
|
||||||
@ -34,6 +35,10 @@
|
|||||||
<channel id="command" typeId="command"/>
|
<channel id="command" typeId="command"/>
|
||||||
</channels>
|
</channels>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<property name="thingTypeVersion">1</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<config-description>
|
<config-description>
|
||||||
<parameter name="id" type="integer" min="1" max="8" required="true">
|
<parameter name="id" type="integer" min="1" max="8" required="true">
|
||||||
<label>Partition Id</label>
|
<label>Partition Id</label>
|
||||||
@ -59,6 +64,12 @@
|
|||||||
<description>State of partition</description>
|
<description>State of partition</description>
|
||||||
<state readOnly="true" pattern="%s"/>
|
<state readOnly="true" pattern="%s"/>
|
||||||
</channel-type>
|
</channel-type>
|
||||||
|
<channel-type id="detailedState">
|
||||||
|
<item-type>String</item-type>
|
||||||
|
<label>Detailed Partition State</label>
|
||||||
|
<description>The detailed state of partition (contains sub-states like Stay in Armed, Armed no entry, etc)</description>
|
||||||
|
<state readOnly="true" pattern="%s"/>
|
||||||
|
</channel-type>
|
||||||
<channel-type id="additionalState">
|
<channel-type id="additionalState">
|
||||||
<item-type>String</item-type>
|
<item-type>String</item-type>
|
||||||
<label>Partition Additional States</label>
|
<label>Partition Additional States</label>
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
|
||||||
|
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
|
||||||
|
|
||||||
|
<thing-type uid="paradoxalarm:partition">
|
||||||
|
<instruction-set targetVersion="1">
|
||||||
|
<add-channel id="detailedState">
|
||||||
|
<type>paradoxalarm:detailedState</type>
|
||||||
|
</add-channel>
|
||||||
|
</instruction-set>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
</update:update-descriptions>
|
||||||
Loading…
x
Reference in New Issue
Block a user