|
12 | 12 | */
|
13 | 13 | package org.openhab.binding.netatmo.internal.handler.capability;
|
14 | 14 |
|
15 |
| -import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*; |
16 |
| -import static org.openhab.core.thing.Thing.*; |
17 |
| - |
18 | 15 | import java.util.Collection;
|
19 | 16 | import java.util.HashMap;
|
20 | 17 | import java.util.List;
|
@@ -53,7 +50,7 @@ public class Capability {
|
53 | 50 | protected final ModuleType moduleType;
|
54 | 51 | protected final ThingUID thingUID;
|
55 | 52 |
|
56 |
| - protected boolean firstLaunch; |
| 53 | + protected boolean firstLaunch = true; |
57 | 54 | protected Map<String, String> properties = Map.of();
|
58 | 55 | protected @Nullable String statusReason;
|
59 | 56 |
|
@@ -104,32 +101,18 @@ public class Capability {
|
104 | 101 |
|
105 | 102 | protected void beforeNewData() {
|
106 | 103 | properties = new HashMap<>(thing.getProperties());
|
107 |
| - firstLaunch = properties.isEmpty(); |
108 |
| - if (firstLaunch) { |
109 |
| - properties.put(PROPERTY_THING_TYPE_VERSION, moduleType.thingTypeVersion); |
110 |
| - if (!moduleType.isLogical()) { |
111 |
| - String name = moduleType.apiName.isBlank() ? moduleType.name() : moduleType.apiName; |
112 |
| - properties.put(PROPERTY_MODEL_ID, name); |
113 |
| - properties.put(PROPERTY_VENDOR, VENDOR); |
114 |
| - } |
115 |
| - } |
116 | 104 | statusReason = null;
|
117 | 105 | }
|
118 | 106 |
|
119 | 107 | protected void afterNewData(@Nullable NAObject newData) {
|
120 | 108 | if (!properties.equals(thing.getProperties())) {
|
121 | 109 | thing.setProperties(properties);
|
122 | 110 | }
|
| 111 | + firstLaunch = false; |
123 | 112 | }
|
124 | 113 |
|
125 | 114 | protected void updateNAThing(NAThing newData) {
|
126 |
| - String firmware = newData.getFirmware(); |
127 |
| - if (firmware != null && !firmware.isBlank()) { |
128 |
| - properties.put(PROPERTY_FIRMWARE_VERSION, firmware); |
129 |
| - } |
130 |
| - if (!newData.isReachable()) { |
131 |
| - statusReason = "@text/device-not-connected"; |
132 |
| - } |
| 115 | + // do nothing by default, can be overridden by subclasses |
133 | 116 | }
|
134 | 117 |
|
135 | 118 | protected void updateNAMain(NAMain newData) {
|
@@ -169,11 +152,9 @@ public void initialize() {
|
169 | 152 | }
|
170 | 153 |
|
171 | 154 | public void expireData() {
|
172 |
| - if (!handler.getCapabilities().containsKey(RefreshCapability.class)) { |
173 |
| - CommonInterface bridgeHandler = handler.getBridgeHandler(); |
174 |
| - if (bridgeHandler != null) { |
175 |
| - bridgeHandler.expireData(); |
176 |
| - } |
| 155 | + CommonInterface bridgeHandler = handler.getBridgeHandler(); |
| 156 | + if (bridgeHandler != null && !handler.getCapabilities().containsKey(RefreshCapability.class)) { |
| 157 | + bridgeHandler.expireData(); |
177 | 158 | }
|
178 | 159 | }
|
179 | 160 |
|
|
0 commit comments