brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

Custom characteristic #148

Closed XciD closed 2 years ago

XciD commented 4 years ago

Hello,

I'm trying to define a custom characteristic like here in nodejs:

const TypeChangeTrack = "00000047-0000-1000-8000-656261617577"

type ChangeTrack struct {
    *characteristic.Int
}

func NewChangeTrack() *ChangeTrack {
    char := characteristic.NewInt(TypeChangeTrack)
    char.Format = characteristic.FormatInt32
    char.Perms = []string{characteristic.PermRead, characteristic.PermWrite, characteristic.PermEvents}
    char.SetMinValue(-1)
    char.SetMaxValue(1)
    char.SetStepValue(1)
    char.Description = "Track Change"

    return &ChangeTrack{char}
}

When I add this characteristic, Home+4 report: No Response Any pointer ?

Thanks for your project

brutella commented 4 years ago

It should work if you set a default value.

char.SetValue(0)
XciD commented 4 years ago

Same, not working

192.168.1.249:51641 GET /accessories
{
    "accessories": [{
        "aid": 1,
        "services": [{
            "iid": 1,
            "type": "3E",
            "characteristics": [{
                "iid": 2,
                "type": "14",
                "perms": ["pw"],
                "format": "bool"
            }, {
                "iid": 3,
                "type": "20",
                "perms": ["pr"],
                "value": "Spotify",
                "format": "string"
            }, {
                "iid": 4,
                "type": "21",
                "perms": ["pr"],
                "value": "undefined",
                "format": "string"
            }, {
                "iid": 5,
                "type": "23",
                "perms": ["pr"],
                "value": "Spotify",
                "format": "string"
            }, {
                "iid": 6,
                "type": "30",
                "perms": ["pr"],
                "value": "undefined",
                "format": "string"
            }, {
                "iid": 7,
                "type": "52",
                "perms": ["pr"],
                "value": "undefined",
                "format": "string"
            }]
        }, {
            "iid": 8,
            "type": "49",
            "characteristics": [{
                "iid": 9,
                "type": "25",
                "perms": ["pr", "pw", "ev"],
                "value": false,
                "format": "bool"
            }]
        }, {
            "iid": 10,
            "type": "113",
            "characteristics": [{
                "iid": 11,
                "type": "11A",
                "perms": ["pr", "pw", "ev"],
                "value": false,
                "format": "bool"
            }, {
                "iid": 12,
                "type": "00000047-0000-1000-8000-656261617577",
                "perms": ["pr", "pw", "ev"],
                "description": "Track Change",
                "value": 0,
                "format": "int32",
                "maxValue": 1,
                "minValue": -1,
                "minStep": 1
            }, {
                "iid": 13,
                "type": "119",
                "perms": ["pr", "pw", "ev"],
                "value": 0,
                "format": "uint8",
                "unit": "percentage",
                "maxValue": 100,
                "minValue": 0,
                "minStep": 1
            }]
        }]
    }]
}
brutella commented 2 years ago

Is this still an issue?