Skip to content

How to add Thermostat / HeaterCooler that just Heats? #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
christiantschoerner opened this issue Jun 21, 2020 · 8 comments
Closed

How to add Thermostat / HeaterCooler that just Heats? #108

christiantschoerner opened this issue Jun 21, 2020 · 8 comments

Comments

@christiantschoerner
Copy link

The questions says it all. I have a fan that can just heat but not cool. Which Accessory should I use?

@ccutrer
Copy link
Collaborator

ccutrer commented Jun 23, 2020

You would adjust the TargetHeaterCoolMode characteristic to have an allowed value of only Off and Heat; but that's not currently possible.

@jvaclavovic
Copy link
Contributor

Hello, I'm trying to modify library to support "heating-only" mode. I modified EnumCharacteristic, metod makeBuilder. I replaced minValue/maxValue by list of valid-values. Its works, I have device only with on/off switch without "auto-heat-cool-off" switch. But it works only few (~20) seconds after pairing. Then some update is started and all devices again have "auto-heat-cool-off" switch. Is there any other place in the code that needs to be modified?

public EnumCharacteristic(
  ...
  protected CompletableFuture<JsonObjectBuilder> makeBuilder(int iid) {
    return super.makeBuilder(iid)
        .thenApply(
            builder -> {
              return builder
                  // .add("minValue", 0)
                  // .add("maxValue", maxValue)
                  // .add("minStep", 1)
                  .add("valid-values", validValuesBuilder);

@yfre
Copy link
Contributor

yfre commented Oct 27, 2020

i would suggest to change

  • CurrentHeatingCoolingStateEnum (remove enums you dont need)
  • TargetHeatingCoolingStateEnum (remove enums you dont need)
  • CurrentHeatingCoolingStateCharacteristic (change the maxValue to value you need, e.g. 1)
  • TargetHeatingCoolingStateCharacteristic (change the maxValue to value you need, e.g. 1)

@ccutrer
Copy link
Collaborator

ccutrer commented Oct 27, 2020

@yfre:

I dunno, that seems like a pain to create specific enum/characteristic every time we need to restrict the possible values.

b) for targetheatingcoolingstate, there are multiple combinations that make sense:

  • (off, cool, heat, auto)
  • (off, cool)
  • (off, heat)
  • (heat) - I have multiple thermostat-like devices that cannot be turned off - hot tub heater, pool heater, heated tile floor
  • (cool, heat) - and thus it follows that this and the next combination could also exist in the real world
  • (cool, heat, auto)
    c) there are other characteristics that need the same treatment. Off the top of my head, SecuritySystem target mode comes to mind (HomeKit allows off, stay, away, night; my security system does not have a "night" mode).

Seems like a better solution would be for enum-type characteristics, we add a way to define them with a list of valid values. then just keep re-using the existing Enum for them (you can only restrict, you can't add).

@jvaclavovic : maybe you need to also restrict the values for the CurrentHeatingCoolingState for HomeKit to accept it?

@yfre
Copy link
Contributor

yfre commented Oct 27, 2020

just checked in HAP specification, sub-set of defined enum values is supported by HAP
"2.3.3.1 Valid Characteristic Values
Accessory characteristics that support only a sub-set of the Apple-defined enum values can indicate the supported
values as part of the characteristicʼs metadata."

@jvaclavovic
Copy link
Contributor

jvaclavovic commented Oct 27, 2020

@ccutrer

This is exactly what I'm doing: I have implemented valid-values for EnumCharacteristic, instead of minValue and maxValue, because I think that min,max do not make sense for enum values. I set only INACTIVE and HEATING for CurrentHeaterCoolerStateEnum and HEAT for TargetHeaterCoolerStateEnum and it works - but only for few seconds (~ 30 seconds).

After pairing I have Heating with on/off switch. But after few seconds the Heating switches to off/cool/heat/auto mode. It is some update from HomeKit, not from my side, because I have only implemented initial state and temperature, without any updates.

@yfre

I tried to remove unnecessary values from both enums, but it had no effect :/

@jvaclavovic
Copy link
Contributor

jvaclavovic commented Oct 27, 2020

Oh, I was my stupid mistake... I use repeately JsonArrayBuilder for creating list of valid values, but method build() on this object after creating list removes all values... so this works only for the first time and after accessories update valid-values was sent empty...

So, valid-values on EnumCharacteristics works perfectly and I have "heats-only" HeaterCooler.

Thank you for your help and I apologize for the inconvenience

@ccutrer
Copy link
Collaborator

ccutrer commented Dec 11, 2020

a recent PR implemented proper enums, so you can now build a heating only accessory

@ccutrer ccutrer closed this as completed Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants