]> git.basschouten.com Git - openhab-addons.git/blob
e316dc6a196e11a6162a9bba412a8bc3ee5448ea
[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.paradoxalarm.internal.handlers;
14
15 import static org.openhab.binding.paradoxalarm.internal.handlers.ParadoxAlarmBindingConstants.*;
16
17 import javax.measure.quantity.ElectricPotential;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.paradoxalarm.internal.model.ParadoxInformation;
21 import org.openhab.binding.paradoxalarm.internal.model.ParadoxPanel;
22 import org.openhab.core.library.types.DateTimeType;
23 import org.openhab.core.library.types.QuantityType;
24 import org.openhab.core.library.types.StringType;
25 import org.openhab.core.library.unit.Units;
26 import org.openhab.core.thing.Thing;
27
28 /**
29  * The {@link ParadoxPanelHandler} This is the handler that takes care of the panel related stuff.
30  *
31  * @author Konstantin Polihronov - Initial contribution
32  */
33 @NonNullByDefault
34 public class ParadoxPanelHandler extends EntityBaseHandler {
35
36     public ParadoxPanelHandler(Thing thing) {
37         super(thing);
38     }
39
40     @Override
41     public void initialize() {
42         super.initialize();
43         config = getConfigAs(PanelConfiguration.class);
44     }
45
46     @Override
47     protected void updateEntity() {
48         ParadoxIP150BridgeHandler bridge = (ParadoxIP150BridgeHandler) getBridge().getHandler();
49         ParadoxPanel panel = bridge.getPanel();
50         StringType panelState = panel.isOnline() ? STATE_ONLINE : STATE_OFFLINE;
51         updateState(PANEL_STATE_CHANNEL_UID, panelState);
52         ParadoxInformation panelInformation = panel.getPanelInformation();
53         if (panelInformation != null) {
54             updateProperty(PANEL_SERIAL_NUMBER_PROPERTY_NAME, panelInformation.getSerialNumber());
55             updateProperty(PANEL_TYPE_PROPERTY_NAME, panelInformation.getPanelType().name());
56             updateProperty(PANEL_HARDWARE_VERSION_PROPERTY_NAME, panelInformation.getHardwareVersion().toString());
57             updateProperty(PANEL_APPLICATION_VERSION_PROPERTY_NAME,
58                     panelInformation.getApplicationVersion().toString());
59             updateProperty(PANEL_BOOTLOADER_VERSION_PROPERTY_NAME, panelInformation.getBootLoaderVersion().toString());
60
61             updateState(PANEL_TIME, new DateTimeType(panel.getPanelTime()));
62             updateState(PANEL_INPUT_VOLTAGE, new QuantityType<ElectricPotential>(panel.getVdcLevel(), Units.VOLT));
63             updateState(PANEL_BOARD_VOLTAGE, new QuantityType<ElectricPotential>(panel.getDcLevel(), Units.VOLT));
64             updateState(PANEL_BATTERY_VOLTAGE,
65                     new QuantityType<ElectricPotential>(panel.getBatteryLevel(), Units.VOLT));
66         }
67     }
68 }