merdok / homebridge-miot

Homebridge plugin for devices supporting the Xiaomi miot protocol
MIT License
371 stars 62 forks source link

Expose manually-run Mi Home scenes to HomeKit #474

Closed ahmadnazirafiq closed 1 year ago

ahmadnazirafiq commented 1 year ago

Describe the idea or improvement I have a couple of manual scenes (where we tap to launch manually) to trigger an action or device. Would be nice to have those manual scenes exposed as a switch in Apple Home as well. Other IoT providers like Tuya plugins made this possible by exposing one-time scenes already created in the app as a switch on the Apple Home app.

Describe the solution you'd like This is useful because some devices on Mi Home app uses custom controls and connectivity that is simply not possible with this plugin yet (like turning on a Projector, IR controls, etc). Best example is with the Tuya plugins which while does not support a pet feeder yet, can still be triggered with a scene that was first created in the Tuya app. The plugin simply exposed the manual scene to Apple Home as a switch, that can be triggered manually or as part of an automation.

Benefits This pretty much simplifies the use of device features that are not exposed by this plugin by default (like we have to add the action trigger manually etc).

merdok commented 1 year ago

Hi, could you explain more detailed or even provide an example of your idea. Maybe how would you imagine the config entry would look like and what would be the expected output. I am currently struggling to understand what this would look like.

ahmadnazirafiq commented 1 year ago

I’ll try my best to explain this simpler haha. On the Mi Home app’s automation section, we all aware there’s a manual and auto way of running scenes; as seen below:

Image

If you are familiar or have created the manual scenes on Mi Home app before, we knew that to run the manual scenes, we either have to press it manually via the app, via Siri or via shortcuts saved on the homescreen.

IMG_5928

On the Tuya app (see above), the same way of creating a scene also applies; with the manual way is called as “tap-to-run”. However, the developer of the Tuya homebridge plugins managed to expose these manual scenes to HomeKit as well. Not sure how they did it, but the same scenes appear on HomeKit:

IMG_5929

Get the idea? Now, what if the device we added in the manual scenes in those apps are not natively supported in HomeKit at all? Think of it like this:

Tuya app = Mi Home app Tuya plugin = MIOT plugin

Based on what Tuya plugins do, it doesn’t support pet feeder yet although Tuya app supports it. Here’s how I would describe it for my setup:

  1. On Tuya app, create a manual scene called “Feed Now” to start dispensing with the pet feeder.
  2. On Tuya plugin, login with Tuya credentials as usual, restart Homebridge.
  3. The scene “Feed Now” that we created via Tuya app appears on HomeKit (just like example above).

Hopefully I’m able to explain this better. Besides Tuya plugins, others like SwitchBot plugin does the same too. Eg: If we have an IR remote added on the SwitchBot app, any type of remotes we created on the app were exposed to HomeKit as well.

merdok commented 1 year ago

I still do not quite get the idea 😅 Why not just create an action button in the plugin and wrap it into a scene? If you have more actions then you can add all those actions into a single scene and execute it when needed. I do not quite understand what scenes should the plugin generate and expose to HomeKit? If you need scenes in HomeKit then why not create them there as described above?