merdok / homebridge-miot

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

Possible to Support Projector as TV/STB/Streaming Device? #387

Closed ahmadnazirafiq closed 1 year ago

ahmadnazirafiq commented 1 year ago

Device model fengmi.projector.fm05

Device name Xiaomi Smart Projector (Fengmi Young)

Does the device require a MiCloud connection? Do not know

Anything special about the device? No

I’m not sure if this is even possible but I don’t see any plugin are able to expose a Xiaomi projector as a television/set top box/streaming device to HomeKit. Currently relying on Siri Shortcuts but its unreliable and breaks everytime there’s an iOS update.

F40A217A-9DBA-43C2-A8F1-E45CB79C9E39

merdok commented 1 year ago

It should actually work. You can already do it now, just add the device into the plugin and it should be detected automatically. Although it will be detected as a generic device, you can use the actionButtons and propertyControl to expose to HomeKit whatever you need and be able to control it.

ahmadnazirafiq commented 1 year ago

I did, but it shows as not supported in the Home app, with a generic “home” icon on it and no buttons at all.

CD93DE33-014C-4A7B-BC79-E81379E870C4

With this warning, adding actionButtons or propertyControl yields no response:

E0CAAA35-C869-45D2-8118-25D09A1BD9BF

I should tell you that this projector only showed up on Mi Home app after I’m signing in to the same account on the projector — not by the usual pairing like other accessories.

merdok commented 1 year ago

The plugin does not supports TV accessories yet so that is an expected behavior, but it should not cause any issues. You can post the homebridge debug so i can have a look what it dos not work, it might be that it requires a micloud connection...

ahmadnazirafiq commented 1 year ago

Here's the log:

[08/11/2022, 09:50:47] [homebridge-miot] [Projector] Parsing miot spec! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Using projector type and Projector description for device identification! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Could not identify device! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] No device class found! Falling back to UnknownDevice! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Initializing device services [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Device services: [ "projector", "play-control", "speaker", "message-router", "ble-control" ] [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Initializing device properties [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Device properties: [ "projector:input-control", "speaker:volume", "speaker:mute", "message-router:request", "message-router:response" ] [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Initializing device actions [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Device actions: [ "projector:turn-off", "play-control:play", "play-control:pause", "message-router:post", "ble-control:turn-on" ] [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Initializing device events [08/11/2022, 09:50:47] [homebridge-miot] [Projector] !-!-! Initial - Monitoring all properties !-!-! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Device not supported! Using a generic device with limited properties! Consider requesting device support! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Found cached accessory for this device! Unregistering it first! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Initializing accessory! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Creating Unknown accessory for device Projector! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Found accessory class at ../modules/unknown/UnknownAccessory.js! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Cannot add Projector wrapper! Property not found on the device! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] =A= Creating user specified action buttons! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] =A= Successfully created action button for action: projector:turn-off! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] =P= Creating user specified property wrappers! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] <-W-> Creating TV Input Control wrapper of type Property for property projector:input-control [08/11/2022, 09:50:47] [homebridge-miot] [Projector] <-W-> Property type: Value List! Creating list item switches! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] Successfully created TV Input Control wrapper of type Property! [08/11/2022, 09:50:47] [homebridge-miot] [Projector] =P= Successfully created property control for property: projector:input-control! [08/11/2022, 09:50:48] [homebridge-miot] [Projector] Accessory successfully initialized! [08/11/2022, 09:50:48] [homebridge-miot] [Projector] !-!-! Final - Monitoring all properties !-!-! [08/11/2022, 09:50:48] [homebridge-miot] [Projector] Registering 1 accessories! [08/11/2022, 09:50:48] [homebridge-miot] [Projector] Everything looks good! Initiating property polling! [08/11/2022, 09:50:48] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [08/11/2022, 09:50:48] [homebridge-miot] [Projector] (Protocol) Server listening 0.0.0.0:35917

merdok commented 1 year ago

The log is not enough as I do not see if the property sync is working, meaning if the plugin could connect to the device. You need to post some more log.

ahmadnazirafiq commented 1 year ago

It seems like I can't connect to the projector to turn it on, however I can use the specified propertyControl to turn it off. It only starts connecting once the projector wakes from sleep even though it has already been powered on. Detailed logs with deep log enabled in the plugin:

[14/11/2022, 11:58:18] [homebridge-miot] [Projector] Initializing device services [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Device services: [ "projector", "play-control", "speaker", "message-router", "ble-control" ] [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Initializing device properties [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Device properties: [ "projector:input-control", "speaker:volume", "speaker:mute", "message-router:request", "message-router:response" ] [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Initializing device actions [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Device actions: [ "projector:turn-off", "play-control:play", "play-control:pause", "message-router:post", "ble-control:turn-on" ] [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Initializing device events [14/11/2022, 11:58:18] [homebridge-miot] [Projector] !-!-! Initial - Monitoring all properties !-!-! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Successfully created a custom accessory device! It is a Projector. Make sure to configure the properties and actions! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Found cached accessory for this device! Unregistering it first! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Initializing accessory! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Creating Custom accessory for device Projector! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Found accessory class at ../modules/custom/CustomAccessory.js! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] =A= Creating user specified action buttons! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] =A= Successfully created action button for action: projector:turn-off! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] =P= Creating user specified property wrappers! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] <-W-> Creating TV Input Control wrapper of type Property for property projector:input-control [14/11/2022, 11:58:18] [homebridge-miot] [Projector] <-W-> Property type: Value List! Creating list item switches! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] Successfully created TV Input Control wrapper of type Property! [14/11/2022, 11:58:18] [homebridge-miot] [Projector] =P= Successfully created property control for property: projector:input-control! [14/11/2022, 11:58:19] [homebridge-miot] [Projector] Accessory successfully initialized! [14/11/2022, 11:58:19] [homebridge-miot] [Projector] !-!-! Final - Monitoring all properties !-!-! [14/11/2022, 11:58:19] [homebridge-miot] [Projector] Registering 1 accessories! [14/11/2022, 11:58:19] [homebridge-miot] [Projector] Everything looks good! Initiating property polling! [14/11/2022, 11:58:19] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [14/11/2022, 11:58:19] [homebridge-miot] [Projector] (Protocol) Server listening 0.0.0.0:39594 [14/11/2022, 12:00:30] [homebridge-miot] [Projector] Error: Could not connect to device, handshake timeout [14/11/2022, 12:00:30] [homebridge-miot] [Projector] Error during connection! Retrying in 60 seconds! [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Handshake reply [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) Call 192.168.1.160: miIO.info - {"timeout":5000,"retries":3} - {} [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- (2) {"method":"miIO.info","params":{"timeout":5000,"retries":3},"id":1} [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- !1p ��cq�]a���,����H$� [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Data: {"partner_id":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","id":1,"code":0,"message":"ok","result":{"hw_ver":"Android","fw_ver":"2.2.1_248","ap":{"rssi":-10,"ssid":"Terminal","bssid":"14:91:82:ab:32:53"},"netif":{"localIp":"192.168.1.160","mask":"0.0.0.0","gw":"192.168.1.1"},"ble_mac":"D0:D9:4F:EE:16:36","model":"fengmi.projector.fm05","mac":"18:93:7f:68:ab:b4","token":"65797a46397033547243367779496f42","life":58}} [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Message: {"partner_id":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","id":1,"code":0,"message":"ok","result":{"hw_ver":"Android","fw_ver":"2.2.1_248","ap":{"rssi":-10,"ssid":"Terminal","bssid":"14:91:82:ab:32:53"},"netif":{"localIp":"192.168.1.160","mask":"0.0.0.0","gw":"192.168.1.1"},"ble_mac":"D0:D9:4F:EE:16:36","model":"fengmi.projector.fm05","mac":"18:93:7f:68:ab:b4","token":"65797a46397033547243367779496f42","life":58}} [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Device found! Setting up miot device from local connection! [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Device firmware: 2.2.1_248 [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Full device info: { "hw_ver": "Android", "fw_ver": "2.2.1_248", "ap": { "rssi": -10, "ssid": "Terminal", "bssid": "14:91:82:ab:32:53" }, "netif": { "localIp": "192.168.1.160", "mask": "0.0.0.0", "gw": "192.168.1.1" }, "ble_mac": "D0:D9:4F:EE:16:36", "model": "fengmi.projector.fm05", "mac": "18:93:7f:68:ab:b4", "token": "65797a46397033547243367779496f42", "life": 58 } [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Connected to device: fengmi.projector.fm05 [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Doing initial property fetch. [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Preparing property poll! [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Splitting properties into chunks. Number of chunks: 1. Chunk size: 14 [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Chunks: [ [ "projector:input-control", "speaker:volume", "speaker:mute" ] ] [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) Call 192.168.1.160: get_properties - [{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":2,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":2}] - {} [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- (2) {"method":"get_properties","params":[{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":2,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":2}],"id":2} [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- !1� ��cq�]VE��"���*�rQ(�) [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Successfully saved device info! [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Data: { "code": 0, "message": "", "result": [ { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 2, "piid": 1, "value": 4, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 1, "value": 17, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 2, "value": false, "code": 0 } ], "id": 2 } [14/11/2022, 12:04:45] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Message: { "code": 0, "message": "", "result": [ { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 2, "piid": 1, "value": 4, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 1, "value": 17, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 2, "value": false, "code": 0 } ], "id": 2 } [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Successfully updated property chunk! RAW: [{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":2,"piid":1,"value":4,"code":0},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":1,"value":17,"code":0},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":2,"value":false,"code":0}] [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Got initial device properties: [ "projector:input-control: 4", "speaker:volume: 17", "speaker:mute: false" ] [14/11/2022, 12:04:45] [homebridge-miot] [Projector] Starting property polling. [14/11/2022, 12:04:55] [homebridge-miot] [Projector] Preparing property poll! [14/11/2022, 12:04:55] [homebridge-miot] [Projector] Splitting properties into chunks. Number of chunks: 1. Chunk size: 14 [14/11/2022, 12:04:55] [homebridge-miot] [Projector] Chunks: [ [ "projector:input-control", "speaker:volume", "speaker:mute" ] ] [14/11/2022, 12:04:55] [homebridge-miot] [Projector] (Protocol) Call 192.168.1.160: get_properties - [{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":2,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":2}] - {} [14/11/2022, 12:04:55] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [14/11/2022, 12:04:55] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- (2) {"method":"get_properties","params":[{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":2,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":1},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":2}],"id":3} [14/11/2022, 12:04:55] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- !1� ��cq�g��:���!��r��y� [14/11/2022, 12:04:55] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Data: { "code": 0, "message": "", "result": [ { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 2, "piid": 1, "value": 4, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 1, "value": 17, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 2, "value": false, "code": 0 } ], "id": 3 } [14/11/2022, 12:04:55] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 -> Message: { "code": 0, "message": "", "result": [ { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 2, "piid": 1, "value": 4, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 1, "value": 17, "code": 0 }, { "did": "mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971", "siid": 4, "piid": 2, "value": false, "code": 0 } ], "id": 3 } [14/11/2022, 12:04:55] [homebridge-miot] [Projector] Successfully updated property chunk! RAW: [{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":2,"piid":1,"value":4,"code":0},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":1,"value":17,"code":0},{"did":"mitv.896dd855dcacb00dc47a7ab4123bbaed:933265df83be4ac0b656f064b2578971","siid":4,"piid":2,"value":false,"code":0}] [14/11/2022, 12:04:55] [homebridge-miot] [Projector] Device properties updated: [ "projector:input-control: 4", "speaker:volume: 17", "speaker:mute: false" ] [14/11/2022, 12:08:25] [homebridge-miot] [Projector] (Protocol) Start handshake 192.168.1.160 [14/11/2022, 12:08:25] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- (0) {"method":"miIO.info","params":{"timeout":5000,"retries":3},"id":1219} [14/11/2022, 12:08:25] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- !1p ��cq�9?�CAU���F��K [14/11/2022, 12:08:29] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- Reached maximum number of retries, giving up miIO.info - {"timeout":5000,"retries":3} [14/11/2022, 12:08:29] [homebridge-miot] [Projector] (Protocol) 192.168.1.160 <- Error during send! (timeout) Call to device timed out | Request: {"method":"miIO.info","params":{"timeout":5000,"retries":3},"id":1219} [14/11/2022, 12:08:29] [homebridge-miot] [Projector] Error: Call to device timed out [14/11/2022, 12:08:29] [homebridge-miot] [Projector] Error during connection! Retrying in 60 seconds!

merdok commented 1 year ago

Yeah, it seems that it only has a turn off action, so I guess that it goes in some kind of a deep sleep when in standby hence it is not possible to turn it on. But besides that it looks good I guess.

ahmadnazirafiq commented 1 year ago

Yeah, but the weird thing is there is one device that can remotely turn on the projector: Mi Smart Clock (xiaomi.wifispeaker.lx04).

See below the manual automation I made in Mi Home app, in addition of the other skills it can do VS the spec fetcher gained from it.

224D6C7A-05B4-4466-A8B8-DDACB8647ACE

The thing is I struggled to put those data for propertyControls and Action buttons as none of them seem to work. If the projector was indeed in deep sleep, why is this smart clock were the only device that can wake it up remotely?

merdok commented 1 year ago

It might be that the device uses wake on lan to wake up. You can try to send a magic packet using generic wake on lan tools to the MAC address of your device to test it out. In the miot spec there is nothing to turn it on hence it will never work over the miot protocol. It also makes sense since the device only can listen to protocol calls when it is turned on and running.

ahmadnazirafiq commented 1 year ago

After tested it myself, it seems like:

  1. Wake up with CEC - No
  2. Wake on LAN - No
  3. Wake via ADB - No

Despite going into deeper sleep mode and is not on the network, I think the reason why is that Mi Smart Clock were using BLE to turn on the projector (it even shows up on Spec Fetcher, see below). I went so far to even root the projector but no luck.

Screenshot 2022-11-15 at 8 45 31 PM

I wonder if what it says "ble-control:turn-on" is enough of a clue 🤔

merdok commented 1 year ago

Yeah, not really sure what it means. I mean to execute an action the plugin needs to be connected to the device and you say that the device is not available in the network as long as it is turned off... so not really sure how the app does the turn on then.

ahmadnazirafiq commented 1 year ago

I think the app sends the command to the cloud then to the smart clock. the clock then initiates the BLE control to turn on the projector. At least that's how i see it via Mi Home app.

It's okay, guess i'll stick to Shortcuts for now. Thanks!