Skip to content

Commit 4130858

Browse files
committed
New thermostat accessory types
Deprecated the old Thermosat accessory and replaced it with three interfaces, to better reflect the required and optional characteristics.
1 parent dceb4a9 commit 4130858

13 files changed

+182
-161
lines changed
Lines changed: 4 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,16 @@
11
package com.beowulfe.hap.accessories;
22

3-
import java.util.Collection;
4-
import java.util.Collections;
5-
import java.util.concurrent.CompletableFuture;
6-
7-
import com.beowulfe.hap.*;
8-
import com.beowulfe.hap.accessories.properties.ThermostatMode;
9-
import com.beowulfe.hap.impl.services.ThermostatService;
3+
import com.beowulfe.hap.accessories.thermostat.*;
104

115
/**
126
* A thermostat with heating and cooling controls.
137
*
148
* @author Andy Lintner
9+
* @deprecated Use {@link BasicThermostat}, {@link HeatingThermostat}, and {@link CoolingThermostat} instead
1510
*/
16-
public interface Thermostat extends HomekitAccessory, TemperatureSensor {
17-
18-
/**
19-
* Retrieves the current {@link ThermostatMode} of the thermostat.
20-
* @return a future that will contain the mode.
21-
*/
22-
CompletableFuture<ThermostatMode> getCurrentMode();
23-
24-
/**
25-
* Subscribes to changes in the {@link ThermostatMode} of the thermostat.
26-
* @param callback the function to call when the state changes.
27-
*/
28-
void subscribeCurrentMode(HomekitCharacteristicChangeCallback callback);
29-
30-
/**
31-
* Unsubscribes from changes in the mode of the thermostat.
32-
*/
33-
void unsubscribeCurrentMode();
34-
35-
/**
36-
* Sets the {@link ThermostatMode} of the thermostat.
37-
* @param mode The {@link ThermostatMode} to set.
38-
* @throws Exception when the change cannot be made.
39-
*/
40-
void setTargetMode(ThermostatMode mode) throws Exception;
41-
42-
/**
43-
* Retrieves the pending, but not yet complete, {@link ThermostatMode} of the thermostat.
44-
* @return a future that will contain the target mode.
45-
*/
46-
CompletableFuture<ThermostatMode> getTargetMode();
47-
48-
/**
49-
* Subscribes to changes in the pending, but not yet complete, {@link ThermostatMode} of the thermostat.
50-
* @param callback the function to call when the state changes.
51-
*/
52-
void subscribeTargetMode(HomekitCharacteristicChangeCallback callback);
53-
54-
/**
55-
* Unsubscribes from changes in the pending, but not yet complete, {@link ThermostatMode} of the thermostat.
56-
*/
57-
void unsubscribeTargetMode();
58-
59-
/**
60-
* Retrieves the target temperature, in celsius degrees, used when the thermostat is in {@link ThermostatMode#AUTO} mode.
61-
* @return a future that will contain the target temperature.
62-
*/
63-
CompletableFuture<Double> getTargetTemperature();
64-
65-
/**
66-
* Sets the target temperature when in {@link ThermostatMode#AUTO} mode.
67-
* @param value the target temperature, in celsius degrees.
68-
* @throws Exception when the temperature cannot be changed.
69-
*/
70-
void setTargetTemperature(Double value) throws Exception;
71-
72-
/**
73-
* Subscribes to changes in the target temperature.
74-
* @param callback the function to call when the state changes.
75-
*/
76-
void subscribeTargetTemperature(HomekitCharacteristicChangeCallback callback);
77-
78-
/**
79-
* Unsubscribes from changes in the target temperature.
80-
*/
81-
void unsubscribeTargetTemperature();
82-
83-
/**
84-
* Retrieves the temperature below which the thermostat should begin heating. Used when the thermostat is in
85-
* {@link ThermostatMode#HEAT} mode.
86-
* @return a future that will contain the threshold temperature, in celsius degrees.
87-
*/
88-
CompletableFuture<Double> getHeatingThresholdTemperature();
89-
90-
/**
91-
* Sets the temperature below which the thermostat should begin heating. Used when the thermostat is in
92-
* {@link ThermostatMode#HEAT} mode.
93-
* @param value the threshold temperature, in celsius degrees.
94-
* @throws Exception when the threshold temperature cannot be changed.
95-
*/
96-
void setHeatingThresholdTemperature(Double value) throws Exception;
97-
98-
/**
99-
* Subscribes to changes in the heating threshold.
100-
* @param callback the function to call when the state changes.
101-
*/
102-
void subscribeHeatingThresholdTemperature(HomekitCharacteristicChangeCallback callback);
103-
104-
/**
105-
* Unsubscribes from changes in the heating threshold.
106-
*/
107-
void unsubscribeHeatingThresholdTemperature();
108-
109-
/**
110-
* Retrieves the temperature above which the thermostat should begin cooling. Used when the thermostat is in
111-
* {@link ThermostatMode#COOL} mode.
112-
* @return a future that will contain the threshold temperature, in celsius degrees.
113-
*/
114-
CompletableFuture<Double> getCoolingThresholdTemperature();
115-
116-
/**
117-
* Sets the temperature above which the thermostat should begin cooling. Used when the thermostat is in
118-
* {@link ThermostatMode#COOL} mode.
119-
* @param value the threshold temperature, in celsius degrees.
120-
* @throws Exception when the threshold temperature cannot be changed.
121-
*/
122-
void setCoolingThresholdTemperature(Double value) throws Exception;
123-
124-
/**
125-
* Subscribes to changes in the cooling threshold.
126-
* @param callback the function to call when the state changes.
127-
*/
128-
void subscribeCoolingThresholdTemperature(HomekitCharacteristicChangeCallback callback);
11+
@Deprecated
12+
public interface Thermostat extends BasicThermostat, HeatingThermostat, CoolingThermostat {
12913

130-
/**
131-
* Unsubscribes from changes in the cooling threshold.
132-
*/
133-
void unsubscribeCoolingThresholdTemperature();
13414

135-
@Override
136-
default Collection<Service> getServices() {
137-
return Collections.singleton(new ThermostatService(this));
138-
}
13915

14016
}

src/main/java/com/beowulfe/hap/accessories/properties/TemperatureUnit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import java.util.Map;
55
import java.util.stream.Collectors;
66

7-
import com.beowulfe.hap.accessories.Thermostat;
7+
import com.beowulfe.hap.accessories.TemperatureSensor;
88

99
/**
10-
* The temperature unit used by a {@link Thermostat}.
10+
* The temperature unit used by a {@link TemperatureSensor}.
1111
*
1212
* @author Andy Lintner
1313
*/

src/main/java/com/beowulfe/hap/accessories/properties/ThermostatMode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import java.util.Map;
55
import java.util.stream.Collectors;
66

7-
import com.beowulfe.hap.accessories.Thermostat;
7+
import com.beowulfe.hap.accessories.thermostat.BasicThermostat;
88

99
/**
10-
* The mode used by a {@link Thermostat}
10+
* The mode used by a {@link BasicThermostat}
1111
*
1212
* @author Andy Lintner
1313
*/
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.beowulfe.hap.accessories.thermostat;
2+
3+
import java.util.Collection;
4+
import java.util.Collections;
5+
import java.util.concurrent.CompletableFuture;
6+
7+
import com.beowulfe.hap.*;
8+
import com.beowulfe.hap.accessories.TemperatureSensor;
9+
import com.beowulfe.hap.accessories.properties.ThermostatMode;
10+
import com.beowulfe.hap.impl.services.ThermostatService;
11+
12+
public interface BasicThermostat extends HomekitAccessory, TemperatureSensor {
13+
14+
/**
15+
* Retrieves the current {@link ThermostatMode} of the thermostat.
16+
* @return a future that will contain the mode.
17+
*/
18+
CompletableFuture<ThermostatMode> getCurrentMode();
19+
20+
/**
21+
* Subscribes to changes in the {@link ThermostatMode} of the thermostat.
22+
* @param callback the function to call when the state changes.
23+
*/
24+
void subscribeCurrentMode(HomekitCharacteristicChangeCallback callback);
25+
26+
/**
27+
* Unsubscribes from changes in the mode of the thermostat.
28+
*/
29+
void unsubscribeCurrentMode();
30+
31+
/**
32+
* Sets the {@link ThermostatMode} of the thermostat.
33+
* @param mode The {@link ThermostatMode} to set.
34+
* @throws Exception when the change cannot be made.
35+
*/
36+
void setTargetMode(ThermostatMode mode) throws Exception;
37+
38+
/**
39+
* Retrieves the pending, but not yet complete, {@link ThermostatMode} of the thermostat.
40+
* @return a future that will contain the target mode.
41+
*/
42+
CompletableFuture<ThermostatMode> getTargetMode();
43+
44+
/**
45+
* Subscribes to changes in the pending, but not yet complete, {@link ThermostatMode} of the thermostat.
46+
* @param callback the function to call when the state changes.
47+
*/
48+
void subscribeTargetMode(HomekitCharacteristicChangeCallback callback);
49+
50+
/**
51+
* Unsubscribes from changes in the pending, but not yet complete, {@link ThermostatMode} of the thermostat.
52+
*/
53+
void unsubscribeTargetMode();
54+
55+
/**
56+
* Retrieves the target temperature, in celsius degrees.
57+
* @return a future that will contain the target temperature.
58+
*/
59+
CompletableFuture<Double> getTargetTemperature();
60+
61+
/**
62+
* Sets the target temperature.
63+
* @param value the target temperature, in celsius degrees.
64+
* @throws Exception when the temperature cannot be changed.
65+
*/
66+
void setTargetTemperature(Double value) throws Exception;
67+
68+
/**
69+
* Subscribes to changes in the target temperature.
70+
* @param callback the function to call when the state changes.
71+
*/
72+
void subscribeTargetTemperature(HomekitCharacteristicChangeCallback callback);
73+
74+
/**
75+
* Unsubscribes from changes in the target temperature.
76+
*/
77+
void unsubscribeTargetTemperature();
78+
79+
@Override
80+
default Collection<Service> getServices() {
81+
return Collections.singleton(new ThermostatService(this));
82+
}
83+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.beowulfe.hap.accessories.thermostat;
2+
3+
import java.util.concurrent.CompletableFuture;
4+
5+
import com.beowulfe.hap.HomekitCharacteristicChangeCallback;
6+
7+
public interface CoolingThermostat extends BasicThermostat {
8+
9+
/**
10+
* Retrieves the temperature above which the thermostat should begin cooling.
11+
* @return a future that will contain the threshold temperature, in celsius degrees.
12+
*/
13+
CompletableFuture<Double> getCoolingThresholdTemperature();
14+
15+
/**
16+
* Sets the temperature above which the thermostat should begin cooling.
17+
* @param value the threshold temperature, in celsius degrees.
18+
* @throws Exception when the threshold temperature cannot be changed.
19+
*/
20+
void setCoolingThresholdTemperature(Double value) throws Exception;
21+
22+
/**
23+
* Subscribes to changes in the cooling threshold.
24+
* @param callback the function to call when the state changes.
25+
*/
26+
void subscribeCoolingThresholdTemperature(HomekitCharacteristicChangeCallback callback);
27+
28+
/**
29+
* Unsubscribes from changes in the cooling threshold.
30+
*/
31+
void unsubscribeCoolingThresholdTemperature();
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.beowulfe.hap.accessories.thermostat;
2+
3+
import java.util.concurrent.CompletableFuture;
4+
5+
import com.beowulfe.hap.HomekitCharacteristicChangeCallback;
6+
7+
public interface HeatingThermostat extends BasicThermostat {
8+
9+
/**
10+
* Retrieves the temperature below which the thermostat should begin heating.
11+
* @return a future that will contain the threshold temperature, in celsius degrees.
12+
*/
13+
CompletableFuture<Double> getHeatingThresholdTemperature();
14+
15+
/**
16+
* Sets the temperature below which the thermostat should begin heating.
17+
* @param value the threshold temperature, in celsius degrees.
18+
* @throws Exception when the threshold temperature cannot be changed.
19+
*/
20+
void setHeatingThresholdTemperature(Double value) throws Exception;
21+
22+
/**
23+
* Subscribes to changes in the heating threshold.
24+
* @param callback the function to call when the state changes.
25+
*/
26+
void subscribeHeatingThresholdTemperature(HomekitCharacteristicChangeCallback callback);
27+
28+
/**
29+
* Unsubscribes from changes in the heating threshold.
30+
*/
31+
void unsubscribeHeatingThresholdTemperature();
32+
}

src/main/java/com/beowulfe/hap/impl/characteristics/thermostat/CoolingThresholdTemperatureCharacteristic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import java.util.concurrent.CompletableFuture;
44

55
import com.beowulfe.hap.HomekitCharacteristicChangeCallback;
6-
import com.beowulfe.hap.accessories.Thermostat;
6+
import com.beowulfe.hap.accessories.thermostat.CoolingThermostat;
77

88
public class CoolingThresholdTemperatureCharacteristic extends
99
AbstractTemperatureCharacteristic {
1010

11-
private final Thermostat thermostat;
11+
private final CoolingThermostat thermostat;
1212

13-
public CoolingThresholdTemperatureCharacteristic(Thermostat thermostat) {
13+
public CoolingThresholdTemperatureCharacteristic(CoolingThermostat thermostat) {
1414
super("0000000D-0000-1000-8000-0026BB765291", true, "Temperature above which cooling will be active", thermostat);
1515
this.thermostat = thermostat;
1616
}

src/main/java/com/beowulfe/hap/impl/characteristics/thermostat/CurrentHeatingCoolingModeCharacteristic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import java.util.concurrent.CompletableFuture;
44

55
import com.beowulfe.hap.HomekitCharacteristicChangeCallback;
6-
import com.beowulfe.hap.accessories.Thermostat;
76
import com.beowulfe.hap.accessories.properties.ThermostatMode;
7+
import com.beowulfe.hap.accessories.thermostat.BasicThermostat;
88

99
public class CurrentHeatingCoolingModeCharacteristic extends
1010
AbstractHeatingCoolingModeCharacteristic {
1111

12-
private final Thermostat thermostat;
12+
private final BasicThermostat thermostat;
1313

14-
public CurrentHeatingCoolingModeCharacteristic(Thermostat thermostat) {
14+
public CurrentHeatingCoolingModeCharacteristic(BasicThermostat thermostat) {
1515
super("0000000F-0000-1000-8000-0026BB765291", false, "Current Mode");
1616
this.thermostat = thermostat;
1717
}

src/main/java/com/beowulfe/hap/impl/characteristics/thermostat/HeatingThresholdTemperatureCharacteristic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import java.util.concurrent.CompletableFuture;
44

55
import com.beowulfe.hap.HomekitCharacteristicChangeCallback;
6-
import com.beowulfe.hap.accessories.Thermostat;
6+
import com.beowulfe.hap.accessories.thermostat.HeatingThermostat;
77

88
public class HeatingThresholdTemperatureCharacteristic extends
99
AbstractTemperatureCharacteristic {
1010

11-
private final Thermostat thermostat;
11+
private final HeatingThermostat thermostat;
1212

13-
public HeatingThresholdTemperatureCharacteristic(Thermostat thermostat) {
13+
public HeatingThresholdTemperatureCharacteristic(HeatingThermostat thermostat) {
1414
super("00000012-0000-1000-8000-0026BB765291", true, "Temperature below which heating will be active", thermostat);
1515
this.thermostat = thermostat;
1616
}

src/main/java/com/beowulfe/hap/impl/characteristics/thermostat/TargetHeatingCoolingModeCharacteristic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import java.util.concurrent.CompletableFuture;
44

55
import com.beowulfe.hap.HomekitCharacteristicChangeCallback;
6-
import com.beowulfe.hap.accessories.Thermostat;
76
import com.beowulfe.hap.accessories.properties.ThermostatMode;
7+
import com.beowulfe.hap.accessories.thermostat.BasicThermostat;
88

99
public class TargetHeatingCoolingModeCharacteristic extends
1010
AbstractHeatingCoolingModeCharacteristic {
1111

12-
private final Thermostat thermostat;
12+
private final BasicThermostat thermostat;
1313

14-
public TargetHeatingCoolingModeCharacteristic(Thermostat thermostat) {
14+
public TargetHeatingCoolingModeCharacteristic(BasicThermostat thermostat) {
1515
super("00000033-0000-1000-8000-0026BB765291", false, "Target Mode");
1616
this.thermostat = thermostat;
1717
}

0 commit comments

Comments
 (0)