homebridge / homebridge-plugin-template

A template you can use to create your own Homebridge plugins.
https://developers.homebridge.io/
Apache License 2.0
315 stars 133 forks source link

Array in custom characteristic #61

Open Julius-Bendt opened 1 year ago

Julius-Bendt commented 1 year ago

Describe Your Problem: I'm trying to create a custom characteristic that shows an array of string. I'm using the home+ 6 app, which are able to show custom characteristics.

I've created the characteristic based on this issue: https://github.com/homebridge/homebridge-plugin-template/issues/20 (as linked in the README file)

I'm able get the custom characteristic to show, but only if I'm not using the "array" format

I've tried to lookup how saturation in the lightbulb works, however I could only find the definitions.

Code:

import { Formats, Perms, CharacteristicProps } from 'homebridge';

export = (homebridge) => {
  const Charact = homebridge.hap.Characteristic;

  return class EffectCharacteristic extends Charact {
    public static readonly UUID: string = 'f8d871fa-a67a-43fe-872d-5250f055d17c';
      constructor() {

        const options: CharacteristicProps = {
            format: Formats.ARRAY, // UINT16 works
            unit: '',
            validValues: [0,1,2,3,4,5,6,7], // Also tried with strings. Removing this allows the accessory to be shown, but not edited
            perms: [Perms.PAIRED_READ, Perms.NOTIFY],
        }

        super('Effect', EffectCharacteristic.UUID, options);
        this.value = 0; // And with a string down here
    }
  };
};

Github repo: https://github.com/Julius-Bendt/homebridge-hyperion

Logs: None - no errors thrown

Plugin Config:

{
    "name": "HyperionJub",
    "url": "http://192.168.1.107",
    "port": "8090",
    "priority": 50,
    "platform": "HyperionJub"
}

Screenshots:

image

Environment: