Git Product home page Git Product logo

Comments (17)

itavero avatar itavero commented on May 12, 2024 3

I made an initial generic stateless switch implementation as mentioned above.
Unfortunately, I'm not yet 100% convinced that this automatic detection will be really useful.
So far I've not been able to add text labels that are visible in the Home app, so out of the box it is not really clear which state (on, off, open, close, ...) is button 1, 2, etcetera.

I might investigate this approach a bit further to see if there is a way to make it more consistent.
However, I think the most usable implementation will be the other suggestion I posted before, for which users need to add their buttons in the JSON configuration.
This can configuration could either be on a device level or on a product type/model level.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024 2

The exposes attribute is available in the latest release of zigbee2mqtt (when the new API is turned on via the configuration.yml). With this new information I can continue working on the implementation I've suggested earlier.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

I'm exploring some options for this, as I really miss this functionality myself.

Right now I'm leaning towards making it possible to configure this via the JSON configuration.
That way I can make something that can work for all switches (for as far as HomeKit supports it).

For the click key in the MQTT message, I might be able to make a "generic" stateless programmable switch implementation.
This would mean that, unless you have provided a custom configuration, you will get a stateless programmable switch for each "value" seen in the click property (on, off, up, down, ...)
These generic switches will only trigger "single presses".

I'll work on the generic stateless programmable switch implementation first. After that I'll think about what the configuration for custom stateless and stateful programmable switches should look like.

from homebridge-z2m.

khituras avatar khituras commented on May 12, 2024

Thank you very much for the plugin so far and especially your work and thoughts on this issue. Integrating an Aqara Opple Switch (of which there are the following models: https://www.zigbee2mqtt.io/devices/WXCJKG11LM.html, https://www.zigbee2mqtt.io/devices/WXCJKG12LM.html and https://www.zigbee2mqtt.io/devices/WXCJKG13LM.html) is my main interest right now.
As you already noticed, switches do not behave uniformly and the Opple Switch doesn't make things easier. Its published MQTT messages look like this:

topic 'zigbee2mqtt/Switch', payload '{"action":"button_1_single","battery":100,"linkquality":12,"voltage":3105}'

The event name is always the value of the action property. Different actions are encoded in this value. Possibilities are:

button_x_single
button_x_double
button_x_hold which is then followed by button_x_release

where x is the button number which currently lies in 1-6.

Do you think you can integrate this in you current work? That would be amazing. If you're too short on time I would also be willing to contribute. However, this issue sounds like you're still thinking about it and I don't want to rush forward and come up with a solution that doesn't fit your thoughts. Also I have no expertise in homebridge plugins or TypeScript, just as a disclaimer. It doesn't actually look that complicated so I would think of this is a major problem but I guess you should know.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

This Opple switch actually looks far more easy to integrate than the remote controls I have from IKEA, Xiaomi and Philips.
However, I would prefer to have a generic solution that fits at least 80% (just to name a number) of the remote controls currently supported by zigbee2mqtt.

Within zigbee2mqtt, a new property is being defined to make it clear what kind of information/actions a device exposes (see Koenkk/zigbee2mqtt#4466). My plan is to make a proposal in the next week or so, on how zigbee2mqtt can expose information about switches in such a way that I can "automagically" convert it to a HomeKit button.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

Some discussion in the earlier mentioned issue in the zigbee2mqtt project (about the new exposes field they are adding), gave me the idea that maybe it is better to use some boolean sensor service (for instance ContactSensor and expose all the different action values that way.

In the future I might be able to make some smart mappings for specific devices if they have usable action values for each of the events that the ProgrammableSwitchEvent characteristic expects.
That way for the user there is no confusion as to which events are supported and which are not.
For this the new exposes field in zigbee2mqtt will probably help for quick discovery.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

Apparently I didn't know the full extend of the HomeKit APIs. After poking around in some other Homebridge plugins I figured out that it should be possible to limit the available events. This does offer some interesting capabilities.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

I'll start over with implementing this, but I think the real "zero configuration" option will have to wait until zigbee2mqtt is released with the exposes property in the device information.
For now, I'll put the necessary information in the JSON configuration file.

I want to know all possible action values upfront, so I can filter out the "unique" buttons by filtering on certain suffixes. Afterwards I can use these alphabetical order of these unique button names as the number for the button in the HomeKit app (since there are no textual labels).

Suffixes that I've seen so far that should be filtered out to discover the "unique" button name:

  • _click
  • _single
  • _hold
  • _release
  • _double

These suffixes can be used to determine the different HomeKit events:

  • Single Press:
    • _click
    • _single
    • ..or if none of the known suffixes is present.
  • Double Press:
    • _double
  • Long Press:
    • _hold

The _release suffix can probably ignored in the event mapping. I had a quick look in fromZigbee.js (part of zigbee-herdsman-converters) and didn't see any device that did support the _release, but no the _hold value.

As far as I can tell, this should also work without any issue for the switches you mention, @khituras.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

This one is pretty high on my list after #18 is finished.

from homebridge-z2m.

rkeyzer9 avatar rkeyzer9 commented on May 12, 2024

Hi i am a little new in the domotic things i have attached a button using zigbee2mqtt thanks for that bit in HomeKit it says it is not supported and van do anything with it, do you have Some ideas were to look for a solution? It is a sonoff ewelink wb01.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

@rkeyzer9 If you use this plugin, then it will indeed show up as unsupported, as this feature is not yet implemented (which is why this issue is still open). 😉
I hope to add support for this in January, if everything around #18 goes well.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

There are a couple of devices that support the action property in zigbee2mqtt, but don't have a definitive list of possible values in the device model.
In devices.js (part of zigbee-herdsman-converters), these device models have something like this in the exposes property:

exposes: [e.action(['recall_*']), e.switch()]

For the device to work, it should contain the absolute values, without the * wildcard.
Luckily it is only limited to a few devices, so for now I'm going to ignore these values.
If people run into it, they should probably open a PR for zigbee-herdsman-converters to add the absolute values.

For the GreenPower_2 devices (like the Hue Tap and Friends of Hue wall switches), I will probably add an option to exclude/ignore certain values.
This is needed because there are several different green power devices, but zigbee2mqtt cannot distinguish between them and therefore the model contains all the known possible values. (also see Koenkk/zigbee-herdsman-converters#2012)

Note that for now GreenPower_7 devices (from EnOcean) are also not supported, as these only list a '*' wildcard as possible value.

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

Support has been added in v1.1.0-beta.0, which is currently available on the next channel.
Additional documentation can be found on the website.

If you already have zigbee2mqtt v1.17.0 running, be sure to give it a try.
(If not, be sure to consider updating soon! 😉)

This issue will be closed.
If you have any related questions/bugs, you may post them here or simply open up a new issue.

from homebridge-z2m.

kwolniak avatar kwolniak commented on May 12, 2024

Hello @itavero, first, thanks for amazing Work!

In my case:
homebridge-z2m v1.1.3
Zigbee2MQTT v1.18.2

I have this button: https://z2m.dev/devices/xiaomi/wxkg06lm.html
I set legacy: false for this button in Zigbee2MQTT configuration file.

It appers in HomeKit app, and also in homebridge accesories, but when I assign action in homekit app to this button, for example single press, it is not working when I push the button, nothing heppens.

The event is visible in Zigbee2MQTT log, for example:

Info MQTT publish: topic 'zigbee2mqtt/Hall Lights Switch Office', payload '{"action":"single","battery":100,"linkquality":21,"voltage":3195}'
Info MQTT publish: topic 'zigbee2mqtt/Hall Lights Switch Office', payload '{"action":"hold","battery":100,"linkquality":21,"voltage":3195}'
Info MQTT publish: topic 'zigbee2mqtt/Hall Lights Switch Office', payload '{"action":"single","battery":100,"linkquality":21,"voltage":3195}'
Info MQTT publish: topic 'zigbee2mqtt/Hall Lights Switch Office', payload '{"action":"single","battery":100,"linkquality":21,"voltage":3195}'
Info MQTT publish: topic 'zigbee2mqtt/Hall Lights Switch Office', payload '{"action":"double","battery":100,"linkquality":21,"voltage":3195}'

so it looks like event is not passed to homebridge and homekit.

Probably I'm doing something wrong but IDK what.
What should I do to make this work?

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

@kwolniak Can you check the Homebridge logs upon startup? It should show the mapping of the button. Maybe that reveals the problem?

If not, please open a bug report issue and fill in the information requested in the issue template.

from homebridge-z2m.

kwolniak avatar kwolniak commented on May 12, 2024

@itavero in Homebridge logs I see only this:

Mapping of property 'action' of device 'Hall Lights Switch Office':
Button 1 (left):
        - SINGLE: single_left
        - DOUBLE: double_left
        - LONG  : hold_left
Button 2 (right):
        - SINGLE: single_right
        - DOUBLE: double_right
        - LONG  : hold_right

But I'm not sure if it's correct and if I have to change something.
In my home app this button is visible like this:
image

from homebridge-z2m.

itavero avatar itavero commented on May 12, 2024

@kwolniak Can you open a new issue for this and also add the MQTT messages sent from Zigbee2MQTT when you press one of the buttons?

from homebridge-z2m.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.