]> git.basschouten.com Git - openhab-addons.git/blob
b5068c7b5421f95ee8294852480323c35f8a926e
[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.loxone.internal.controls;
14
15 import static org.openhab.binding.loxone.internal.LxBindingConstants.*;
16
17 import org.openhab.binding.loxone.internal.types.LxUuid;
18 import org.openhab.core.library.types.StringType;
19 import org.openhab.core.thing.ChannelUID;
20 import org.openhab.core.thing.type.ChannelTypeUID;
21 import org.openhab.core.types.StateDescriptionFragment;
22 import org.openhab.core.types.StateDescriptionFragmentBuilder;
23
24 /**
25  * A web page type of control on Loxone Miniserver.
26  *
27  * @author Pawel Pieczul - initial contribution
28  *
29  */
30 class LxControlWebPage extends LxControl {
31     static class Factory extends LxControlInstance {
32         @Override
33         LxControl create(LxUuid uuid) {
34             return new LxControlWebPage(uuid);
35         }
36
37         @Override
38         String getType() {
39             return "webpage";
40         }
41     }
42
43     private StringType url;
44     private StringType urlHd;
45
46     private LxControlWebPage(LxUuid uuid) {
47         super(uuid);
48     }
49
50     @Override
51     public void initialize(LxControlConfig config) {
52         super.initialize(config);
53         if (details != null) {
54             if (details.url != null) {
55                 url = new StringType(details.url);
56             }
57             if (details.urlHd != null) {
58                 urlHd = new StringType(details.urlHd);
59             }
60         }
61         StateDescriptionFragment fragment = StateDescriptionFragmentBuilder.create().withReadOnly(true).build();
62         ChannelUID c1 = addChannel("String", new ChannelTypeUID(BINDING_ID, MINISERVER_CHANNEL_TYPE_RO_TEXT),
63                 defaultChannelLabel + " / URL", "Low resolution URL", tags, null, () -> url);
64         addChannelStateDescriptionFragment(c1, fragment);
65
66         ChannelUID c2 = addChannel("String", new ChannelTypeUID(BINDING_ID, MINISERVER_CHANNEL_TYPE_RO_TEXT),
67                 defaultChannelLabel + " / URL HD", "High resolution URL", tags, null, () -> urlHd);
68         addChannelStateDescriptionFragment(c2, fragment);
69     }
70 }