]> git.basschouten.com Git - openhab-addons.git/blob
5ff6b5b110e39b1069ac07f6d00b9be1b3f75297
[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.mqtt.ruuvigateway.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.mqtt.generic.ChannelConfig;
17 import org.openhab.binding.mqtt.generic.ChannelState;
18 import org.openhab.binding.mqtt.generic.values.TextValue;
19 import org.openhab.core.library.types.StringType;
20 import org.openhab.core.thing.ChannelUID;
21
22 /**
23  * Simplified state cache for purposes of caching StringType values
24  *
25  * Unlike parent class {@link ChannelState}, this class by definition is not interacting with MQTT subscriptions nor
26  * does it update any channels
27  *
28  * @author Sami Salonen - Initial contribution
29  */
30 @NonNullByDefault
31 public class RuuviCachedStringState extends ChannelState {
32
33     /**
34      * Construct cache for Strings
35      *
36      * @param channelUID associated channel UID
37      *
38      */
39     public RuuviCachedStringState(ChannelUID channelUID) {
40         super(new ChannelConfig(), channelUID, new TextValue(), null);
41     }
42
43     /**
44      * Update cached state with given value
45      *
46      * @param value value. Specified as plain number with unit given in constructor
47      */
48     public void update(String value) {
49         cachedValue.update(new StringType(value));
50     }
51 }