2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.loxone.internal.controls;
15 import static org.openhab.binding.loxone.internal.LxBindingConstants.*;
17 import org.openhab.binding.loxone.internal.types.LxCategory;
18 import org.openhab.binding.loxone.internal.types.LxTags;
19 import org.openhab.binding.loxone.internal.types.LxUuid;
20 import org.openhab.core.thing.ChannelUID;
21 import org.openhab.core.thing.type.ChannelTypeUID;
22 import org.openhab.core.types.StateDescriptionFragmentBuilder;
25 * An InfoOnlyAnalog type of control on Loxone Miniserver.
27 * According to Loxone API documentation, this control covers analog virtual states only. This control does not send any
28 * commands to the Miniserver. It can be used to read a formatted representation of an analog virtual state.
30 * @author Pawel Pieczul - initial contribution
33 class LxControlInfoOnlyAnalog extends LxControl {
35 static class Factory extends LxControlInstance {
37 LxControl create(LxUuid uuid) {
38 return new LxControlInfoOnlyAnalog(uuid);
43 return "infoonlyanalog";
48 * InfoOnlyAnalog state with current value
50 private static final String STATE_VALUE = "value";
52 private LxControlInfoOnlyAnalog(LxUuid uuid) {
57 public void initialize(LxControlConfig config) {
58 super.initialize(config);
59 LxCategory category = getCategory();
60 if (category != null && category.getType() == LxCategory.CategoryType.TEMPERATURE) {
61 tags.addAll(LxTags.TEMPERATURE);
63 ChannelUID cid = addChannel("Number", new ChannelTypeUID(BINDING_ID, MINISERVER_CHANNEL_TYPE_RO_ANALOG),
64 defaultChannelLabel, "Analog virtual state", tags, null, () -> getStateDecimalValue(STATE_VALUE));
66 if (details != null && details.format != null) {
67 format = details.format;
71 addChannelStateDescriptionFragment(cid,
72 StateDescriptionFragmentBuilder.create().withPattern(format).withReadOnly(true).build());