karlentwistle / ruby_home

Ruby HAP Server - HomeKit support for the Rubyist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change maximum/minimum/step values of a numeric characteristic?

vickash opened this issue · comments

I'm implementing a split AC unit with no heater, starting from the included heater/cooler example. Removing the unneeded characteristics from the ServiceFactory call works fine, and I can prevent the "Heat" option from showing up with the following code, inserted just after it:

heater_cooler.characteristics.each do |c|
  if c.name == :target_heater_cooler_state
    c.constraints["ValidValues"].delete("1")
  end
end

I also want to limit the temperature between 17 and 31C in 1C steps, but the same strategy doesn't work there:

heater_cooler.characteristics.each do |c|
  if c.name == :cooling_threshold_temperature
    c.constraints["MaximumValue"] = 31
    c.constraints["MinimumValue"] = 17
    c.constraints["StepValue"] = 1
  end
end

The slider on my phone still shows 10 to 35C in 0.5C steps. Any ideas? Thanks.

Thanks for writing this issue @vickash. I'm so sorry for my late response. I realised RubyHome needs to include part of the HomeKit Accessory Protocol to expose this behaviour. I have a WIP PR #126, but I want to add some automated tests before merging it.

Hopefully, this will resolve your issue.

Excellent. Thanks. I'll give it a try once you're done.