forked from hap-java/HAP-Java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from hap-java/master
merge with upstream
- Loading branch information
Showing
7 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 18 additions & 3 deletions
21
...ava/io/github/hapjava/impl/characteristics/thermostat/TemperatureUnitsCharacteristic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
package io.github.hapjava.impl.characteristics.thermostat; | ||
|
||
import io.github.hapjava.HomekitCharacteristicChangeCallback; | ||
import io.github.hapjava.accessories.properties.TemperatureUnit; | ||
import io.github.hapjava.accessories.thermostat.BasicThermostat; | ||
import io.github.hapjava.characteristics.EnumCharacteristic; | ||
import io.github.hapjava.characteristics.EventableCharacteristic; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class TemperatureUnitsCharacteristic extends EnumCharacteristic { | ||
public class TemperatureUnitsCharacteristic extends EnumCharacteristic | ||
implements EventableCharacteristic { | ||
|
||
private final BasicThermostat thermostat; | ||
|
||
public TemperatureUnitsCharacteristic(BasicThermostat thermostat) { | ||
super("00000036-0000-1000-8000-0026BB765291", false, true, "The temperature unit", 1); | ||
super("00000036-0000-1000-8000-0026BB765291", true, true, "The temperature unit", 1); | ||
this.thermostat = thermostat; | ||
} | ||
|
||
@Override | ||
protected void setValue(Integer value) throws Exception { | ||
// Not writable | ||
thermostat.setTemperatureUnit( | ||
value == 1 ? TemperatureUnit.FAHRENHEIT : TemperatureUnit.CELSIUS); | ||
} | ||
|
||
@Override | ||
protected CompletableFuture<Integer> getValue() { | ||
return CompletableFuture.completedFuture(thermostat.getTemperatureUnit().getCode()); | ||
} | ||
|
||
@Override | ||
public void subscribe(final HomekitCharacteristicChangeCallback callback) { | ||
thermostat.subscribeTemperatureUnit(callback); | ||
} | ||
|
||
@Override | ||
public void unsubscribe() { | ||
thermostat.unsubscribeTemperatureUnit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters