2 * Copyright (c) 2010-2020 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.nikohomecontrol.internal.handler;
15 import java.net.InetAddress;
16 import java.util.HashMap;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.nikohomecontrol.internal.protocol.nhc1.NikoHomeControlCommunication1;
21 import org.openhab.core.thing.Bridge;
22 import org.openhab.core.thing.ThingStatus;
23 import org.openhab.core.thing.ThingStatusDetail;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * {@link NikoHomeControlBridgeHandler1} is the handler for a Niko Home Control I IP-interface and connects it to
31 * @author Mark Herwege - Initial Contribution
34 public class NikoHomeControlBridgeHandler1 extends NikoHomeControlBridgeHandler {
36 private final Logger logger = LoggerFactory.getLogger(NikoHomeControlBridgeHandler1.class);
38 public NikoHomeControlBridgeHandler1(Bridge nikoHomeControlBridge) {
39 super(nikoHomeControlBridge);
43 public void initialize() {
44 logger.debug("Niko Home Control: initializing bridge handler");
47 InetAddress addr = getAddr();
50 logger.debug("Niko Home Control: bridge handler host {}, port {}", addr, port);
53 nhcComm = new NikoHomeControlCommunication1(this, scheduler);
56 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
57 "Niko Home Control: cannot resolve bridge IP with hostname " + config.addr);
62 protected void updateProperties() {
63 Map<String, String> properties = new HashMap<>();
65 NikoHomeControlCommunication1 comm = (NikoHomeControlCommunication1) nhcComm;
67 properties.put("softwareVersion", comm.getSystemInfo().getSwVersion());
68 properties.put("apiVersion", comm.getSystemInfo().getApi());
69 properties.put("language", comm.getSystemInfo().getLanguage());
70 properties.put("currency", comm.getSystemInfo().getCurrency());
71 properties.put("units", comm.getSystemInfo().getUnits());
72 properties.put("tzOffset", comm.getSystemInfo().getTz());
73 properties.put("dstOffset", comm.getSystemInfo().getDst());
74 properties.put("configDate", comm.getSystemInfo().getLastConfig());
75 properties.put("energyEraseDate", comm.getSystemInfo().getLastEnergyErase());
76 properties.put("connectionStartDate", comm.getSystemInfo().getTime());
78 thing.setProperties(properties);