]> git.basschouten.com Git - openhab-addons.git/blob
5fcc2ac7a88b2cf645db514f556e0acafc70c8ca
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.homewizard.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.library.types.QuantityType;
17 import org.openhab.core.library.unit.SIUnits;
18 import org.openhab.core.library.unit.Units;
19 import org.openhab.core.thing.ChannelUID;
20 import org.openhab.core.thing.Thing;
21 import org.openhab.core.types.Command;
22
23 /**
24  * The {@link HomeWizardWaterMeterHandler} implements functionality to handle a HomeWizard Watermeter.
25  *
26  * @author DaniĆ«l van Os - Initial contribution
27  */
28 @NonNullByDefault
29 public class HomeWizardWaterMeterHandler extends HomeWizardDeviceHandler {
30
31     /**
32      * Constructor
33      *
34      * @param thing The thing to handle
35      */
36     public HomeWizardWaterMeterHandler(Thing thing) {
37         super(thing);
38     }
39
40     /**
41      * Not listening to any commands.
42      */
43     @Override
44     public void handleCommand(ChannelUID channelUID, Command command) {
45     }
46
47     /**
48      * Device specific handling of the returned payload.
49      *
50      * @param payload The data parsed from the Json file
51      */
52     @Override
53     protected void handleDataPayload(DataPayload payload) {
54         updateState(HomeWizardBindingConstants.CHANNEL_CURRENT_WATER,
55                 new QuantityType<>(payload.getCurrentWaterLPM(), Units.LITRE_PER_MINUTE));
56         updateState(HomeWizardBindingConstants.CHANNEL_TOTAL_WATER,
57                 new QuantityType<>(payload.getTotalWaterM3(), SIUnits.CUBIC_METRE));
58     }
59 }