Skip to content

Linked Services #104

Closed
Closed

Description

@scothi

Are there any plans to implement the Linked Services logic?
I'm implementing - or at least trying to - the Television service which comes with two linked services (InputSource and TelevisionSpeaker) but I am having difficulties. I tried to add this functionality but it's not clear for me what is linked to what. Is the "sub" service linked to the "main" service or the linked attribute contains the sub service's ids?

Activity

  1. yfre commented on Mar 30, 2020

    @yfre
    Contributor

    i have implemented it for my irrigation system which has to be linked to valve services. but it was more hack than proper implementation.
    in terms what is linked to what i would say, main services has an array with linked services IDs.

  2. scothi commented on Mar 31, 2020

    @scothi
    Author

    Ok, thanks. Now it’s working. :)

  3. yfre commented on Mar 31, 2020

    @yfre
    Contributor

    cool. will you push your changes to your repository or create PR here? i would love to integrate your changes to my branch.

  4. scothi commented on Apr 1, 2020

    @scothi
    Author

    PR sent #105

  5. dfrommi commented on Sep 30, 2020

    @dfrommi
    Contributor

    @scothi So you have a working Television service?
    Would you mind sharing it, esp. the missing characteristics? I tried the same but I just can't get it working.
    No exceptions or errors, but the accessory is still shown as "not available" in the home app.
    I suspect that something is wrong with the characteristics, but I just can't find it.

  6. gjvanderheiden commented on Dec 10, 2020

    @gjvanderheiden
    Contributor

    Could

    public void addLinkedService(Service service)

    be added to the interface Service.

    I don't see how I can add a linked service when using hap-java.

    AbstractServiceImpl isn't accessible. I ran into problems when adding FilterMaintenanceAccessory. The service it's linked to can't be added as a linked service now.

  7. gjvanderheiden commented on Dec 10, 2020

    @gjvanderheiden
    Contributor

    I would like to do this:

    HomekitAccessory accessory = new MockSwitch(...);
    accessory.addLinkedAccessory(new MockBatteryAccessory());

  8. yfre commented on Dec 10, 2020

    @yfre
    Contributor

    yes, i have proposed the addLinkedAccessory as well but decided against it in order to be consistent with Characterstics which has addCharacteristics only at AbstractServiceImpl but not in the interface.

    as of now you can do this
    accessory.getServices().add(new Service())

    but maybe we should really introduce addLinkedService at Service interface. maybe also the addCharacteristic as well. it is more developer friendly imo.

  9. yfre commented on Dec 10, 2020

    @yfre
    Contributor

    @gjvanderheiden you are completely right, without adding addLinkedService to Service interface we cannot use it. it was working only with test mock client as i could overwrite getService there.
    and it is also correct to add addCharacteristics to Service interface. characteristics are fixed and the developer should not add them manually one-by-one.
    let me prepare a PR with changes

  10. dfrommi commented on Dec 10, 2020

    @dfrommi
    Contributor

    I actually thought it could used like this:

    • Some service is implementing AbstractServiceImpl, let's say TelevisionService
    • The TelevisionService would expose a method like addInputSource(InputSourceService s)
      • this would be implemented as super.addLinkedService(s)

    Do you see a problem with this approach?

    You can't link arbitrary services, so type-safety imho would make sense.

  11. yfre commented on Dec 10, 2020

    @yfre
    Contributor

    this is the approach @gjvanderheiden was also proposing - dedicated methods.

    my idea was to keep it more flexible as services can be combined in many different ways and HAP does not restrict it. e.g. you can add battery service to lightbulb or switch and home app shows it correctly.
    other examples are fan, slat and sensors which can be added to many other services like AirPurifier, Heating and other.
    so, we would need to add many methods for almost all combinations.

  12. dfrommi commented on Dec 10, 2020

    @dfrommi
    Contributor

    Ah, I see.
    Didn't know that you can combine arbitrary services. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions