2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.paradoxalarm.internal.handlers;
15 import static org.openhab.binding.paradoxalarm.internal.handlers.ParadoxAlarmBindingConstants.*;
17 import javax.measure.quantity.ElectricPotential;
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 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * The {@link ParadoxPanelHandler} This is the handler that takes care of the panel related stuff.
33 * @author Konstantin Polihronov - Initial contribution
36 public class ParadoxPanelHandler extends EntityBaseHandler {
38 private final Logger logger = LoggerFactory.getLogger(ParadoxPanelHandler.class);
40 public ParadoxPanelHandler(Thing thing) {
45 public void initialize() {
47 config = getConfigAs(PanelConfiguration.class);
51 protected void updateEntity() {
52 ParadoxIP150BridgeHandler bridge = (ParadoxIP150BridgeHandler) getBridge().getHandler();
53 ParadoxPanel panel = bridge.getPanel();
54 StringType panelState = panel.isOnline() ? STATE_ONLINE : STATE_OFFLINE;
55 updateState(PANEL_STATE_CHANNEL_UID, panelState);
56 ParadoxInformation panelInformation = panel.getPanelInformation();
57 if (panelInformation != null) {
58 updateProperty(PANEL_SERIAL_NUMBER_PROPERTY_NAME, panelInformation.getSerialNumber());
59 updateProperty(PANEL_TYPE_PROPERTY_NAME, panelInformation.getPanelType().name());
60 updateProperty(PANEL_HARDWARE_VERSION_PROPERTY_NAME, panelInformation.getHardwareVersion().toString());
61 updateProperty(PANEL_APPLICATION_VERSION_PROPERTY_NAME,
62 panelInformation.getApplicationVersion().toString());
63 updateProperty(PANEL_BOOTLOADER_VERSION_PROPERTY_NAME, panelInformation.getBootLoaderVersion().toString());
65 updateState(PANEL_TIME, new DateTimeType(panel.getPanelTime()));
66 updateState(PANEL_INPUT_VOLTAGE, new QuantityType<ElectricPotential>(panel.getVdcLevel(), Units.VOLT));
67 updateState(PANEL_BOARD_VOLTAGE, new QuantityType<ElectricPotential>(panel.getDcLevel(), Units.VOLT));
68 updateState(PANEL_BATTERY_VOLTAGE,
69 new QuantityType<ElectricPotential>(panel.getBatteryLevel(), Units.VOLT));