Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Grouped accessories IOS13 #201

Open
Kepete opened this issue Jan 27, 2020 · 25 comments
Open

Feature request - Grouped accessories IOS13 #201

Kepete opened this issue Jan 27, 2020 · 25 comments

Comments

@Kepete
Copy link

Kepete commented Jan 27, 2020

With IOS 13 it's now possible to have different tiles (accessorise) grouped into one tile. While long pressing on it it will reveal them.
For example it's possible to have two switches grouped:
IMG_2342

I think this has been discussed under different issues few times, but though it would need it's own discussion.

@Kepete Kepete changed the title Future request - Grouped accessories IOS13 Feature request - Grouped accessories IOS13 Jan 27, 2020
@arachnetech
Copy link
Owner

I think this is the functionality that Jacob Nite added in 1.0.50?

@Kepete
Copy link
Author

Kepete commented Apr 5, 2020

Hmm, as I have understood no, it's not the same thing. Jacob Nite added a button which does not have a state(ON or OFF) so you can press it once, twice or long press to perform a different actions on the same button.

I'm talking about the new feature(which many hated) that came with IOS13. This groups different accessorise that are under one device into one single tile.

It is explained for example here: https://9to5mac.com/2019/08/20/homekit-ios-13/
But it's not only for temp and humidity. See from my screenshot, it's also for switches one light and one on/off switch(and I hope all accessorise).

In one tile:
IMG_2810

If force press/long press to open the additional view:
IMG_2811

@Kepete
Copy link
Author

Kepete commented Apr 5, 2020

It would be awesome if we could group accessorise by common name somewhere in the config.
For example:

  "accessory": "mqttthing",
  "type": "lightbulb",
  "name": "My lightbulb",
  "url": "http://192.168.1.235:1883",
  "username": "MQTT_username",
  "password": "MQTT_password",
  **"group": "MY_GROUP"**

So then if two accessories have the same group name they would be displayed in homekit in the one tile that you can open up to see and interact independently

@arachnetech
Copy link
Owner

Thanks, @Kepete. Do you have any idea how groups are represented by HomeKit types? I can’t see anything obvious in https://github.com/KhaosT/HAP-NodeJS/blob/master/src/lib/gen/HomeKit.ts.

@Kepete
Copy link
Author

Kepete commented Apr 6, 2020

@arachnetech not sure about HomeKit types, but found an issue explaining it further on HAP-NodeJS git. https://github.com/KhaosT/HAP-NodeJS/issues/680

Furthermore, I have one Homebridge plugin(the same I shared screenshots of) that grouped tiles after IOS13 update automatically, so maybe you can figure it out from the code. The plugin is:
https://github.com/skrollme/homebridge-philipstv-x

Maybe this helps :)

@tobekas
Copy link
Contributor

tobekas commented Apr 8, 2020

You get this grouping, if you add multiple "functional" services to one accessory. For example multiple "switch" services, or "motionsensor" combined with "lightbulb".
So the concept is not to use different accessories with a common group name, but to provide a single accessory object, which (by the way) can only have one "AccessoryInformationService". So if you provide multiple services, they have to share AccessoryName, Model, Serial, FWVersion. However every Service can have its own name (characteristic). So far, typically only the service-name was visible.

In this Plugin we already have this grouping feature for type "WheatherStation", which I added some time ago. It provides Temperature & Humidity services (+some special Eve-only services) in just one accessory. You can check out the code for this...

The main conceptual problem is that homebridge-mqttthing is based on different accessory types with fixed assigned services/characteristics. It may be worthwhile to implement kind of a "flexible" type with a combination of multiple services, which was already discussed in #144 and #149.

@arachnetech
Copy link
Owner

Thanks, that’s very helpful. Certainly sounds possible, but probably only directly through the XML (not config-ui-x).

@tobekas
Copy link
Contributor

tobekas commented Apr 9, 2020

Yes. This might be too complex for config-Ui-x. I could imagine this kind of json configuration:

"accessory": "mqttthing",
    "type": "custom",
    "name": "My accessory Name",
    "url": "mqtt://192.168.1.234",
    "services": [
        {
            "type": "switch",
            "name": "Switch 1",
            "topics": {
                "getOn": "home/get/switch1/POWER",
                "setOn": "home/set/switch1/POWER"
            },
            "integerValue": true
        },
        {
            "type": "switch",
            "name": "Switch 2",
            "topics": {
                "getOn": "home/get/switch2/POWER",
                "setOn": "home/set/switch2/POWER"
            },
            "integerValue": true
        },
        {
            "type": "motionSensor",
            "name": "My PIR",
            "topics": {
                "getMotionDetected": "home/get/pir/STATUS",
                "getStatusActive": "home/get/pir/ACTIVE",
                "getStatusFault": "home/get/pir/FAULT",
                "getStatusLowBattery": "home/get/pir/BATLOW"
            },
            "onValue": "MOTION"
        }
    ]
}

Where appropriate, common options could also be specified outside of "services".

As inner types, however, one should only use simple types that provide only one service. So complex ones like Doorbell with motion, WeatherStation, TV should not be used. And there could only exist one BatteryService!

@Kepete
Copy link
Author

Kepete commented Apr 9, 2020

Thanks @tobekas for your input. This is exactly what I was looking for when posting this feature request. Your configuration example makes sense and would work well.

@superjunky
Copy link

superjunky commented Jun 7, 2020

And how about an extra option for grouped switches: "isDefaultOn".
A single switch in a group can be defined as the "default on". If a switch in a group has this property set to true, the group acts as a radio button group that always has one option "selected". This means if all switches are set to OFF, the switch that is marked as "default on" is set to ON.

Reason: Homekit is lacking selector-switches (I.E. the same way a tv-accessory works).

Based on this plugin: https://www.npmjs.com/package/homebridge-dummy-radio-switch

@Kepete
Copy link
Author

Kepete commented Jun 9, 2020

@arachnetech is there some works done about this feature request?
Or currently it's on hold until more resources are available? :)

@arachnetech
Copy link
Owner

Still waiting for me to find some time, unfortunately. Thanks for reminding me though - maybe during the weekend...

@psyciknz
Copy link

psyciknz commented Jun 30, 2020

i just put in a group fir a xiaomi item in the openhab package. its configurtion was relatively straight forward.

                    "type": "group",
                    "name": "Gateway",
                    "model": "Xiaomi Gateway",
                    "items": [
                        {
                            "item": "xiaomi_gateway_color",
                            "type": "light",
                            "name": "Xiaomi"
                        },
                        {
                            "item": "xiaomi_gateway_lightswitch",
                            "type": "light",
                            "name": "Xiaomi Switch"
                        }
                    ]
                }

so fir mqttthing, I'd guess the item, types would be thing definitions , as per if they were listed individually.

arachnetech added a commit that referenced this issue Jul 9, 2020
@arachnetech
Copy link
Owner

This is looking hopeful...
image

@psyciknz
Copy link

That looks really good

@Kepete
Copy link
Author

Kepete commented Jul 10, 2020

Wow, I'm excited!

Are there any limitations which accessories you can group together? For example does Apple allow grouping Curtains with Light Dimmer(an unusual group) ors.

@arachnetech
Copy link
Owner

Thanks! It's in the multi-service branch currently if you want a look (and don't mind navigating git). I'll do a test release later. There were some quite significant changes to the structure of the plugin so I'd prefer to be cautious, although the amount of new code was surprisingly limited.

I haven't implemented any limitations, but I suspect Homekit might impose some. So far I've only tested the combination shown above, which uses the configuration proposed by @tobekas above.

@Hans0lo
Copy link

Hans0lo commented Jul 14, 2020

Hi there,
thnx for your work, I really enjoy using it.
I use a Gosund SP112 outlet that has additional USB ports that can be switched individually from the main outlet.
I currently have configured the 'USB switch' as a second accessory, and that works fine.
this is the config file as I used it:

{
            "accessory": "mqttthing",
            "type": "outlet",
            "name": "Gosund-01",
            "url": "mqtt://localhost",
            "username": "xxxxxx",
            "password": "xxxxxx",
            "mqttPubOptions": {
                "retain": true
            },
            "history": "true",
            "onValue": "ON",
            "offValue": "OFF",
            "logMqtt": true,
            "onlineValue": "Online",
            "manufacturer": "Gosund",
            "model": "SP112 new",
            "serialNumber": "192.168.xxxxxx",
            "topics": {
                "getInUse": "tele/tasmota-01/STATE",
                "getOn": "stat/tasmota-01/POWER1",
                "setOn": "cmnd/tasmota-01/POWER1",
                "getWatts": {
                    "topic": "tele/tasmota-01/SENSOR",
                    "apply": "return JSON.parse(message).ENERGY.Power;"
                },
                "getVolts": {
                    "topic": "tele/tasmota-01/SENSOR",
                    "apply": "return JSON.parse(message).ENERGY.Voltage;"
                },
                "getAmperes": {
                    "topic": "tele/tasmota-01/SENSOR",
                    "apply": "return JSON.parse(message).ENERGY.Current;"
                }
            },
            "startPub": [
                {
                    "topic": "cmnd/tasmota-01/POWER1",
                    "message": ""
                },
                {
                    "topic": "stat/tasmota-01/POWER1",
                    "message": ""
                }
            ],
            "mqttOptions": {
                "keepalive": 30
            }
        },
        {
            "accessory": "mqttthing",
            "type": "outlet",
            "name": "Gosund-01-USB",
            "url": "mqtt://localhost",
            "username": "xxxxxx",
            "password": "xxxxxx",
            "mqttPubOptions": {
                "retain": true
            },
            "history": "true",
            "onValue": "ON",
            "offValue": "OFF",
            "logMqtt": true,
            "onlineValue": "Online",
            "manufacturer": "Gosund",
            "model": "SP112 new",
            "serialNumber": "192.168.xxxxxx",
            "topics": {
                "getInUse": "tele/tasmota-01/STATE",
                "getOn": "stat/tasmota-01/POWER2",
                "setOn": "cmnd/tasmota-01/POWER2"
            },
            "startPub": [
                {
                    "topic": "cmnd/tasmota-01/POWER2",
                    "message": ""
                },
                {
                    "topic": "stat/tasmota-01/POWER2",
                    "message": ""
                }
            ],
            "mqttOptions": {
                "keepalive": 30
            }
        }

however, when I try to change it to make use of the 1.1.17 multiservice feature, the plug just gets invisible in home app & eve & also in the homebridge accessory page.
this is the config file I thought would match the new feature:

{
            "accessory": "mqttthing",
            "type": "outlet",
            "name": "Gosund-01",
            "url": "mqtt://localhost",
            "username": "xxxxx",
            "password": "xxxxx",
            "mqttPubOptions": {
                "retain": true
            },
            "logMqtt": true,
            "history": "true",
            "onValue": "ON",
            "offValue": "OFF",
            "mqttOptions": {
                "keepalive": 30
            },
            "onlineValue": "Online",
            "manufacturer": "Gosund",
            "model": "SP112 new",
            "serialNumber": "192.168.xxxxx",
            "services": [
                {
                    "type": "switch",
                    "name": "Main",
                    "topics": {
                        "getInUse": "tele/tasmota-01/STATE",
                        "getOn": "stat/tasmota-01/POWER1",
                        "setOn": "cmnd/tasmota-01/POWER1",
                        "getWatts": {
                            "topic": "tele/tasmota-01/SENSOR",
                            "apply": "return JSON.parse(message).ENERGY.Power;"
                        },
                        "getVolts": {
                            "topic": "tele/tasmota-01/SENSOR",
                            "apply": "return JSON.parse(message).ENERGY.Voltage;"
                        },
                        "getAmperes": {
                            "topic": "tele/tasmota-01/SENSOR",
                            "apply": "return JSON.parse(message).ENERGY.Current;"
                        }
                    }
                },
                {
                    "type": "switch",
                    "name": "USB",
                    "topics": {
                        "getInUse": "tele/tasmota-01/STATE",
                        "getOn": "stat/tasmota-01/POWER2",
                        "setOn": "cmnd/tasmota-01/POWER2"
                    }
                }
            ],
            "startPub": [
                {
                    "topic": "cmnd/tasmota-01/POWER1",
                    "message": ""
                },
                {
                    "topic": "stat/tasmota-01/POWER1",
                    "message": ""
                },
                {
                    "topic": "cmnd/tasmota-01/POWER2",
                    "message": ""
                },
                {
                    "topic": "stat/tasmota-01/POWER2",
                    "message": ""
                }
            ]
        }

did I do something wrong, or do you maybe have an idea why this is not working as I expected?
thnx a lot!

@Kepete
Copy link
Author

Kepete commented Jul 31, 2020

Seems like multi-service is in the main branch moving forward from release 1.1.17 ?
Will give it a try next week and report back. Anything to keep in mind while setting it up?

@arachnetech
Copy link
Owner

arachnetech commented Jul 31, 2020

Yes, it's in the main branch now.

@Hans0lo, I think "type": "outlet", in line 2 of your config is wrong. For grouped accessories, you need to use "type": "custom".

There's some very brief documentation at https://github.com/arachnetech/homebridge-mqttthing/blob/master/docs/Configuration.md#grouped-accessories which may help.

@arachnetech
Copy link
Owner

Are there any limitations which accessories you can group together? For example does Apple allow grouping Curtains with Light Dimmer(an unusual group) ors.

To be honest, I don't know without trying it!

@Kepete
Copy link
Author

Kepete commented Aug 3, 2020

@arachnetech Tested and can confirm it works awesome! Thanks again.
And even the interesting combination of curtains and a light dimmer could be grouped.

One small addition. Currently if I group two (dimmable) lights together, I will have to slide to full power both of them separately(two sliders next to each other). Could it be implemented that if you click the tile(accessory) once it goes to ON for all devices in the group(so switching both dimmable lights on) and if you hold long press then it opens the accessory like currently(and then can separately control them).

I don't know maybe it's a limitation from homekit side, but would seem like logical to have a short way of doing things and then long press would give extra info.

@kyrannian
Copy link

I've played around with this feature, and I've noticed if I have "history":"true" on the root custom service, it complains of having multiple services with the same UUID. Upon closer inspection, I can see that the outlet on the custom group service , the history service for it is being allocated the same UUID as another outlet not in a custom service. Removing "history":"true" from the root custom service fixes the problem.

@kyrannian
Copy link

More info, if I have two outlets in a single custom grouping, if you apply history to both it will fail on a duplicate UUID on the history service.

@jeylites
Copy link

jeylites commented Sep 27, 2020

Exactly what we need, Is this still in beta?

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

No branches or pull requests

8 participants