]> git.basschouten.com Git - openhab-addons.git/blob
411c52ebb7a5286b9810048f3ef8a7cc94928e44
[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.boschshc.internal.devices.wallthermostat;
14
15 import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_HUMIDITY;
16 import static org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants.CHANNEL_TEMPERATURE;
17
18 import java.util.List;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.boschshc.internal.devices.BoschSHCDeviceHandler;
22 import org.openhab.binding.boschshc.internal.exceptions.BoschSHCException;
23 import org.openhab.binding.boschshc.internal.services.humiditylevel.HumidityLevelService;
24 import org.openhab.binding.boschshc.internal.services.humiditylevel.dto.HumidityLevelServiceState;
25 import org.openhab.binding.boschshc.internal.services.temperaturelevel.TemperatureLevelService;
26 import org.openhab.binding.boschshc.internal.services.temperaturelevel.dto.TemperatureLevelServiceState;
27 import org.openhab.core.thing.Thing;
28
29 /**
30  * Handler for a wall thermostat device.
31  * 
32  * @author Christian Oeing - Initial contribution
33  */
34 @NonNullByDefault
35 public final class WallThermostatHandler extends BoschSHCDeviceHandler {
36
37     public WallThermostatHandler(Thing thing) {
38         super(thing);
39     }
40
41     @Override
42     protected void initializeServices() throws BoschSHCException {
43         this.createService(TemperatureLevelService::new, this::updateChannels, List.of(CHANNEL_TEMPERATURE));
44         this.createService(HumidityLevelService::new, this::updateChannels, List.of(CHANNEL_HUMIDITY));
45     }
46
47     /**
48      * Updates the channels which are linked to the {@link TemperatureLevelService} of the device.
49      * 
50      * @param state Current state of {@link TemperatureLevelService}.
51      */
52     private void updateChannels(TemperatureLevelServiceState state) {
53         super.updateState(CHANNEL_TEMPERATURE, state.getTemperatureState());
54     }
55
56     /**
57      * Updates the channels which are linked to the {@link HumidityLevelService} of the device.
58      * 
59      * @param state Current state of {@link HumidityLevelService}.
60      */
61     private void updateChannels(HumidityLevelServiceState state) {
62         super.updateState(CHANNEL_HUMIDITY, state.getHumidityState());
63     }
64 }