]> git.basschouten.com Git - openhab-addons.git/blob
0b808fab93bfb4e22d5212cb272b6635b5c89746
[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.List;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.netatmo.internal.handler.CommonInterface;
20 import org.openhab.binding.netatmo.internal.handler.channelhelper.ChannelHelper;
21 import org.openhab.binding.netatmo.internal.handler.channelhelper.EventChannelHelper;
22 import org.openhab.binding.netatmo.internal.providers.NetatmoDescriptionProvider;
23
24 /**
25  * {@link HomeSecurityThingCapability} is the ancestor of capabilities hosted by a security home
26  * e.g. person and camera capabilities
27  *
28  * @author GaĆ«l L'hopital - Initial contribution
29  *
30  */
31 @NonNullByDefault
32 public class HomeSecurityThingCapability extends Capability {
33     protected final NetatmoDescriptionProvider descriptionProvider;
34     protected final EventChannelHelper eventHelper;
35
36     protected Optional<SecurityCapability> securityCapability = Optional.empty();
37     protected Optional<HomeCapability> homeCapability = Optional.empty();
38
39     public HomeSecurityThingCapability(CommonInterface handler, NetatmoDescriptionProvider descriptionProvider,
40             List<ChannelHelper> channelHelpers) {
41         super(handler);
42         this.descriptionProvider = descriptionProvider;
43         this.eventHelper = (EventChannelHelper) channelHelpers.stream().filter(c -> c instanceof EventChannelHelper)
44                 .findFirst().orElseThrow(() -> new IllegalArgumentException(
45                         "HomeSecurityThingCapability must find an EventChannelHelper, please file a bug report."));
46         eventHelper.setModuleType(moduleType);
47     }
48
49     @Override
50     public void initialize() {
51         super.initialize();
52         securityCapability = handler.getHomeCapability(SecurityCapability.class);
53         homeCapability = handler.getHomeCapability(HomeCapability.class);
54     }
55 }