HAP-python icon indicating copy to clipboard operation
HAP-python copied to clipboard

CATEGORY_LIGHTBULB configure_char('Brightness'... ValueError("Characteristic not found"

Open AlexMaghen opened this issue 2 years ago • 1 comments

Thanks for this wonderful library. I am trying to build a LightBulb accessory that can handle dimming. For some reason, I get an error in __init__ when I try to do self.char_brightness = serv_light.configure_char('Brightness', value=100) The error comes back ValueError: Characteristic not found

(extremely simple full accessory file attached)

Any help MOST appreciated. This is driving me nuts! :) HKPoolDial.txt

AlexMaghen avatar Aug 05 '23 14:08 AlexMaghen

Brightness is an optional charactarestic to LightBulb service (see below excerpt from pyhap/resources/services.json), meaning it's not attached to the service by default:

   "Lightbulb": {
      "OptionalCharacteristics": [
         "Brightness",
         "Hue",
         "Saturation",
         "Name",
         "ActiveTransitionCount",
         "TransitionControl",
         "SupportedTransitionConfiguration"
      ],
      "RequiredCharacteristics": [
         "On"
      ],
      "UUID": "00000043-0000-1000-8000-0026BB765291"
   },

Hence, in order to be able to configure brightnes, you should specify it in the initialization of the LightBulb service as following:

self.light_bulb_service = self.add_preload_service('LightBulb', chars=['Brightness'])

Then proceed with configuring the brightness charactarestic as you've done.

cerahmed avatar Sep 10 '23 10:09 cerahmed