2 * Copyright (c) 2010-2022 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.regoheatpump.internal.handler;
15 import org.openhab.binding.regoheatpump.internal.RegoHeatPumpBindingConstants;
16 import org.openhab.binding.regoheatpump.internal.protocol.RegoConnection;
17 import org.openhab.binding.regoheatpump.internal.protocol.SerialRegoConnection;
18 import org.openhab.core.io.transport.serial.SerialPortIdentifier;
19 import org.openhab.core.io.transport.serial.SerialPortManager;
20 import org.openhab.core.thing.Thing;
21 import org.openhab.core.thing.ThingStatus;
22 import org.openhab.core.thing.ThingStatusDetail;
25 * The {@link SerialRego6xxHeatPumpHandler} is responsible for handling commands, which are
26 * sent to one of the channels.
28 * @author Boris Krivonog - Initial contribution
30 public class SerialRego6xxHeatPumpHandler extends Rego6xxHeatPumpHandler {
31 private final SerialPortManager serialPortManager;
32 private SerialPortIdentifier serialPortIdentifier;
34 public SerialRego6xxHeatPumpHandler(Thing thing, SerialPortManager serialPortManager) {
36 this.serialPortManager = serialPortManager;
40 public void initialize() {
41 String portName = (String) getConfig().get(RegoHeatPumpBindingConstants.PORT_NAME);
42 serialPortIdentifier = serialPortManager.getIdentifier(portName);
43 if (serialPortIdentifier == null) {
44 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
45 "Serial port does not exist: " + portName);
52 protected RegoConnection createConnection() {
53 return new SerialRegoConnection(serialPortIdentifier, 19200);