]> git.basschouten.com Git - openhab-addons.git/blob
56de5a1f946085a3068d0d5309f7afd828475233
[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
14 package org.openhab.binding.qbus.internal.protocol;
15
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.openhab.binding.qbus.internal.handler.QbusCO2Handler;
19
20 /**
21  * The {@link QbusCO2} class represents the action Qbus CO2 output.
22  *
23  * @author Koen Schockaert - Initial Contribution
24  */
25
26 @NonNullByDefault
27 public final class QbusCO2 {
28
29     private @Nullable Integer state;
30
31     private @Nullable QbusCO2Handler thingHandler;
32
33     /**
34      * This method should be called if the ThingHandler for the thing corresponding to this CO2 is initialized.
35      * It keeps a record of the thing handler in this object so the thing can be updated when
36      * the CO2 output receives an update from the Qbus IP-interface.
37      *
38      * @param handler
39      */
40     public void setThingHandler(QbusCO2Handler handler) {
41         this.thingHandler = handler;
42     }
43
44     /**
45      * Get state of CO2.
46      *
47      * @return CO2 state
48      */
49     public @Nullable Integer getState() {
50         return this.state;
51     }
52
53     /**
54      * Update the value of the CO2.
55      *
56      * @param CO2 value
57      */
58     void updateState(@Nullable Integer state) {
59         this.state = state;
60         QbusCO2Handler handler = this.thingHandler;
61         if (handler != null) {
62             handler.handleStateUpdate(this);
63         }
64     }
65 }