|
31 | 31 | import org.openhab.binding.netatmo.internal.config.NAThingConfiguration; |
32 | 32 | import org.openhab.binding.netatmo.internal.handler.capability.Capability; |
33 | 33 | import org.openhab.binding.netatmo.internal.handler.capability.CapabilityMap; |
| 34 | +import org.openhab.binding.netatmo.internal.handler.capability.ChannelHelperCapability; |
34 | 35 | import org.openhab.binding.netatmo.internal.handler.capability.HomeCapability; |
35 | 36 | import org.openhab.binding.netatmo.internal.handler.capability.ParentUpdateCapability; |
36 | 37 | import org.openhab.binding.netatmo.internal.handler.capability.RefreshCapability; |
@@ -177,22 +178,29 @@ default <T extends RestCapability<?>> Optional<T> getHomeCapability(Class<T> cla |
177 | 178 | } |
178 | 179 |
|
179 | 180 | default void setNewData(NAObject newData) { |
180 | | - if (newData instanceof NAThing thingData) { |
181 | | - if (getId().equals(thingData.getBridge())) { |
182 | | - getActiveChildren().stream().filter(child -> child.getId().equals(thingData.getId())).findFirst() |
183 | | - .ifPresent(child -> child.setNewData(thingData)); |
184 | | - return; |
185 | | - } |
| 181 | + if (newData instanceof NAThing thingData && getId().equals(thingData.getBridge())) { |
| 182 | + getActiveChildren().stream().filter(child -> child.getId().equals(thingData.getId())). // |
| 183 | + findFirst().ifPresent(child -> child.setNewData(thingData)); |
| 184 | + return; |
186 | 185 | } |
187 | 186 |
|
188 | 187 | String finalReason = null; |
| 188 | + ChannelHelperCapability channelHelper = null; |
189 | 189 | for (Capability cap : getCapabilities().values()) { |
190 | | - String statusReason = cap.setNewData(newData); |
191 | | - if (statusReason != null) { |
192 | | - finalReason = statusReason; |
| 190 | + if (cap instanceof ChannelHelperCapability) { |
| 191 | + channelHelper = (ChannelHelperCapability) cap; |
| 192 | + } else { |
| 193 | + if (cap.setNewData(newData) instanceof String statusReason) { |
| 194 | + finalReason = statusReason; |
| 195 | + } |
193 | 196 | } |
194 | 197 | } |
195 | 198 |
|
| 199 | + // Handle channel updates only if no error was raised |
| 200 | + if (channelHelper != null && finalReason == null) { |
| 201 | + channelHelper.setNewData(newData); |
| 202 | + } |
| 203 | + |
196 | 204 | if (newData.isIgnoredForThingUpdate()) { |
197 | 205 | return; |
198 | 206 | } |
|
0 commit comments