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.nikohomecontrol.internal.handler;
15 import static org.openhab.binding.nikohomecontrol.internal.NikoHomeControlBindingConstants.THREAD_NAME_PREFIX;
17 import java.net.InetAddress;
18 import java.util.HashMap;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.binding.nikohomecontrol.internal.protocol.nhc1.NikoHomeControlCommunication1;
23 import org.openhab.core.i18n.TimeZoneProvider;
24 import org.openhab.core.thing.Bridge;
25 import org.openhab.core.thing.ThingStatus;
26 import org.openhab.core.thing.ThingStatusDetail;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * {@link NikoHomeControlBridgeHandler1} is the handler for a Niko Home Control I IP-interface and connects it to
34 * @author Mark Herwege - Initial Contribution
37 public class NikoHomeControlBridgeHandler1 extends NikoHomeControlBridgeHandler {
39 private final Logger logger = LoggerFactory.getLogger(NikoHomeControlBridgeHandler1.class);
41 public NikoHomeControlBridgeHandler1(Bridge nikoHomeControlBridge, TimeZoneProvider timeZoneProvider) {
42 super(nikoHomeControlBridge, timeZoneProvider);
46 public void initialize() {
47 logger.debug("initializing bridge handler");
49 InetAddress addr = getAddr();
52 logger.debug("bridge handler host {}, port {}", addr, port);
55 String eventThreadName = THREAD_NAME_PREFIX + thing.getUID().getAsString();
56 nhcComm = new NikoHomeControlCommunication1(this, scheduler, eventThreadName);
59 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
60 "@text/offline.configuration-error.ip");
65 protected void updateProperties() {
66 Map<String, String> properties = new HashMap<>();
68 NikoHomeControlCommunication1 comm = (NikoHomeControlCommunication1) nhcComm;
70 properties.put("softwareVersion", comm.getSystemInfo().getSwVersion());
71 properties.put("apiVersion", comm.getSystemInfo().getApi());
72 properties.put("language", comm.getSystemInfo().getLanguage());
73 properties.put("currency", comm.getSystemInfo().getCurrency());
74 properties.put("units", comm.getSystemInfo().getUnits());
75 properties.put("tzOffset", comm.getSystemInfo().getTz());
76 properties.put("dstOffset", comm.getSystemInfo().getDst());
77 properties.put("configDate", comm.getSystemInfo().getLastConfig());
78 properties.put("energyEraseDate", comm.getSystemInfo().getLastEnergyErase());
79 properties.put("connectionStartDate", comm.getSystemInfo().getTime());
81 thing.setProperties(properties);