]> git.basschouten.com Git - openhab-addons.git/blob
be188f1d07871c3a38b2bca2a09485fe3dc44cd2
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.netatmo.internal.handler.capability;
14
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import java.util.List;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
21 import org.openhab.binding.netatmo.internal.api.dto.NAObject;
22 import org.openhab.binding.netatmo.internal.handler.CommonInterface;
23 import org.openhab.binding.netatmo.internal.handler.channelhelper.ChannelHelper;
24 import org.openhab.binding.netatmo.internal.providers.NetatmoDescriptionProvider;
25
26 /**
27  * {@link SmokeCapability} gives the ability to handle Smoke detector specifics
28  *
29  * @author GaĆ«l L'hopital - Initial contribution
30  *
31  */
32 @NonNullByDefault
33 public class SmokeCapability extends HomeSecurityThingCapability {
34
35     public SmokeCapability(CommonInterface handler, NetatmoDescriptionProvider descriptionProvider,
36             List<ChannelHelper> channelHelpers) {
37         super(handler, descriptionProvider, channelHelpers);
38     }
39
40     @Override
41     public List<NAObject> updateReadings() {
42         List<NAObject> result = new ArrayList<>();
43         securityCapability.ifPresent(cap -> {
44             Collection<HomeEvent> events = cap.getDeviceEvents(handler.getId(), moduleType.apiName);
45             if (!events.isEmpty()) {
46                 result.add(events.iterator().next());
47             }
48         });
49         return result;
50     }
51 }