]> git.basschouten.com Git - openhab-addons.git/blob
ea84939e3e4824b3b4fa518c9d9873d4fc10a494
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.boschshc.internal.services.bypass.dto;
14
15 import org.openhab.core.library.types.OnOffType;
16 import org.openhab.core.types.State;
17 import org.openhab.core.types.UnDefType;
18
19 /**
20  * State indicating whether a device is currently bypassed.
21  * 
22  * @author David Pace - Initial contribution
23  *
24  */
25 public enum BypassState {
26     BYPASS_INACTIVE,
27     BYPASS_ACTIVE,
28     UNKNOWN;
29
30     /**
31      * Converts this Bosch-specific bypass state to an openHAB-compliant state for a switch.
32      * 
33      * @return <code>ON</code>, <code>OFF</code> or <code>UNDEF</code>
34      */
35     public State toOnOffTypeOrUndef() {
36         return switch (this) {
37             case BYPASS_ACTIVE -> OnOffType.ON;
38             case BYPASS_INACTIVE -> OnOffType.OFF;
39             default -> UnDefType.UNDEF;
40         };
41     }
42 }