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.nobohub.internal.model;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * A Zone contains one or more {@link Component}s.
21 * @author Jørgen Austvik - Initial contribution
22 * @author Espen Fossen - Initial contribution
25 public final class Zone {
28 private final String name;
29 private int activeWeekProfileId;
30 private int comfortTemperature;
31 private int ecoTemperature;
32 private final boolean allowOverrides;
33 private @Nullable Double temperature;
35 public Zone(int id, String name, int activeWeekProfileId, int comfortTemperature, int ecoTemperature,
36 boolean allowOverrides) throws NoboDataException {
39 this.activeWeekProfileId = activeWeekProfileId;
40 this.comfortTemperature = comfortTemperature;
41 this.ecoTemperature = ecoTemperature;
42 this.allowOverrides = allowOverrides;
45 public static Zone fromH01(String h01) throws NoboDataException {
46 String parts[] = h01.split(" ", 8);
48 if (parts.length != 8) {
49 throw new NoboDataException(
50 String.format("Unexpected number of parts from hub on H1 call: %d", parts.length));
53 return new Zone(Integer.parseInt(parts[1]), ModelHelper.toJavaString(parts[2]), Integer.parseInt(parts[3]),
54 Integer.parseInt(parts[4]), Integer.parseInt(parts[5]), "1".equals(parts[6]));
57 public String generateCommandString(final String command) {
58 return String.join(" ", command, Integer.toString(id), ModelHelper.toHubString(name),
59 Integer.toString(activeWeekProfileId), Integer.toString(comfortTemperature),
60 Integer.toString(ecoTemperature), allowOverrides ? "1" : "0", "-1"); // "Active override id" is
68 public String getName() {
72 public int getActiveWeekProfileId() {
73 return activeWeekProfileId;
76 public int getComfortTemperature() {
77 return comfortTemperature;
80 public int getEcoTemperature() {
81 return ecoTemperature;
84 public boolean getAllowOverrides() {
85 return allowOverrides;
88 public void setTemperature(@Nullable Double temperature) {
89 this.temperature = temperature;
92 public @Nullable Double getTemperature() {
96 public void setComfortTemperature(int temp) {
97 comfortTemperature = temp;
100 public void setEcoTemperature(int temp) {
101 ecoTemperature = temp;
104 public void setWeekProfile(int weekProfileId) {
105 activeWeekProfileId = weekProfileId;