2 * Copyright (c) 2010-2024 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;
29 * The {@link ParadoxPanelHandler} This is the handler that takes care of the panel related stuff.
31 * @author Konstantin Polihronov - Initial contribution
34 public class ParadoxPanelHandler extends EntityBaseHandler {
36 public ParadoxPanelHandler(Thing thing) {
41 public void initialize() {
43 config = getConfigAs(PanelConfiguration.class);
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());
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));