Skip to content

Commit

Permalink
Aligned detailed states with the actual states from the system
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
  • Loading branch information
theater committed Mar 18, 2023
1 parent 8dbe56b commit 7ed0181
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bundles/org.openhab.binding.paradoxalarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Currently binding supports the following panels: EVO192, EVO48(not tested), EVO9
### Partition detailed state possible values:
| Overall state value | Detailed state value (depending on the sub-state) |
|--------------------------|----------------------------------------------------------------------------------------------|
| InAlarm | SilentAlarm, AudibleAlarm, FireAlarm, InAlarm (if none of the first three) |
| Armed | ArmedInAway, ArmedInStay, ArmedInNoEntry, Armed (if none of the first three) |
| 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public PartitionState getState() {

public Partition setState(PartitionState 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 {}:\t{}", getLabel(), getState().getDetailedState());
logger.trace("Partition {}:\t{}", getLabel(), getState());
logger.trace("Partition {} detailed state:\t{}", getLabel(), getState().getDetailedState());
logger.trace("Partition {} full state dump:\t{}", getLabel(), getState());
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
*/
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 isArmedInAway;
private boolean isArmedInStay;
Expand Down Expand Up @@ -48,34 +58,34 @@ public class PartitionState {

public String getMainState() {
if (isInAlarm || isInSilentAlarm || isInAudibleAlarm || isInFireAlarm) {
return "InAlarm";
return IN_ALARM;
} else {
return isArmed || isArmedInAway || isArmedInStay || isArmedInNoEntry ? "Armed" : "Disarmed";
return isArmed || isArmedInAway || isArmedInStay || isArmedInNoEntry ? ARMED : DISARMED;
}
}

public String getDetailedState() {
if (isInAlarm) {
if (isInSilentAlarm) {
return "SilentAlarm";
return SILENT_ALARM;
} else if (isInAudibleAlarm) {
return "AudibleAlarm";
return AUDIBLE_ALARM;
} else if (isInFireAlarm) {
return "FireAlarm";
return FIRE_ALARM;
}
return "InAlarm";
return IN_ALARM;
} else if (isArmed) {
if (isArmedInAway) {
return "ArmedInAway";
return ARMED_IN_AWAY;
} else if (isArmedInStay) {
return "ArmedInStay";
return ARMED_IN_STAY;
} else if (isArmedInNoEntry) {
return "ArmedInNoEntry";
return ARMED_IN_NO_ENTRY;
}
return "Armed";
return ARMED;
}

return "Disarmed";
return DISARMED;
}

@Override
Expand Down

0 comments on commit 7ed0181

Please sign in to comment.