Open Bergasha opened 2 years ago
The hardest part is not HA side, currently I have not figured out how to simulate/fake a bluetooth signal to turn on XGIMI
Updates: The newest XGIMI mobile app now has feature to turn on the projector through bluetooth. There is no pairing required in this procedure, it seems like a BLE advertisement. If so, it is possible to simulate the bluetooth signal to turn on the projector from HA. I tried to analysis btsnoop_hci.log by wireshark but no luck. If anyone is familar with bluetooth protocol and willing to help please DM me :-)
I'd love to see this if you can get it working, unfortunately I don't have any BT experience but commenting to stay subscribed to this issue.
I don't have a solution either but I started a thread as well in the XGIMI Elfin forum (would probably make sense to start in other forums as well with many members): https://www.facebook.com/groups/xgimielfin/posts/864061654795310/?comment_id=864101604791315&reply_comment_id=864118484789627¬if_id=1670170784048565¬if_t=group_comment_mention
I also have an XGIMI projector and I would like to be able to turn it on via the Home assistant. Can this video help in any way? https://www.youtube.com/watch?v=NIBmiPtCDdM&list=PLlGYeZI9ysXKGJuA7f9lZ53Fk9tYO-pDP&index=1&t=317s
I solved it for the XGIMI Elfin 🥳🥳🥳 It has worked for several weeks now. Have a look at my answer here for more instructions.
The only time I wasn't able to turn on the projector was after it had been off for a couple of days. On this occasion a non-paired remote control was still able to turn the projector on, so maybe there's one more advertising scenario I may have not yet understood. But I will have to wait for a couple of days again leaving the projector off before I can further explore this. It's also possible that on this special occasion maybe the BLE advertising app just didn't work properly. To be continued...
I solved it for the XGIMI Elfin 🥳🥳🥳 It has worked for several weeks now. Have a look at my answer here for more instructions.
The only time I wasn't able to turn on the projector was after it had been off for a couple of days. On this occasion a non-paired remote control was still able to turn the projector on, so maybe there's one more advertising scenario I may have not yet understood. But I will have to wait for a couple of days again leaving the projector off before I can further explore this. It's also possible that on this special occasion maybe the BLE advertising app just didn't work properly. To be continued...
Thanks for sharing, that's really a breakthrough. Could you elaborate more on how to get UUID and Manufacturer Specific Data by scanning the remote?
@manymuch You're welcome. For the Xgimi Halo+ there's now also the BLE information available thanks to the contribution of Muxa.
To sniff the information needed I used ubertooth BLE sniffer device with a command like this ubertooth-btle -f -t1C:F3:01:B9:81:99 (the MAC address of the remote control can be easily figured out beforehand). Because the ubertooth was too expensive I didn't keep it, instead I have now ordered a Nordic Semiconductor nRF52840 USB-Dongle which I hope will do work in a similar manner.
You might also be able to get all needed information using a BLE app on your phone. There are a couple available in the app stores and I was also able to see a signal from the XGIMI remote including manufacturer data if I recall right, but it wasn't a very straightforward way to run an analysis.
Another potentially sufficient approach without the need of an extra BLE sniffer device could be bluetoothctl which is part of BLUEZ for linux: https://stackoverflow.com/questions/36607626/how-to-use-bluetoothctl-like-hcitool-lescan-to-report-repeated-proximity-beacons
With hcitool you might be successful as well but hcitool commands only work up to BLE 4.0 devices. You can find such USB dongles for a few bucks online. I ordered one with CSR 8510 A10 chipset (Qualcomm) but haven't found time yet to experiment more with it.
@manymuch I added additional comments here also regarding BLE sniffer experience with Bluetooth Smart Scanner App . The initial post in this thread also refers to this sniffer app. With such app you might not even need a separate BLE sniffer device.
Updates: I powered on my Xgimi projector(z6x) succesfully through EFR connect. Here is the manufacture Specific Data I found by Bluetooth Smart Scanner App: Company Code: 0x0046 Data: 0x12D7C7899B9F80FFFFFF3043524B544D Besides, I have also noticed that the first 4 digits are random Working on next step: using sending BLE with Bluez from raspberrypi, or maybe even from esphome.
Thank you for the update @manymuch and congratulations!
I think I had also been successful with Bluez turning the projector on but right now I'm not able to replicate my previous success. At least I can provide you with some commands that I think work to run advertising signal (just adapt for your data):
bluetoothctl
[bluetooth]# menu advertise [bluetooth]# uuids 0x1812 [bluetooth]# manufacturer 0x46 0x7e 0x31 0xdb 0x31 0xb2 0x24 0x40 0xff 0xff 0xff 0x30 0x43 0x52 0x4b 0x54 0x4d [bluetooth]# back [bluetooth]# advertise on
When you purchase an old BLE 4.0 USB dongle with Cambridge Silicon Radio chipset (it should show Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode) when you run lsusb) you can use hcitool commands which maybe work better than bluetoothctl, but maybe your raspberry bluetooth chipset also supports hcitool. I haven't had time yet to further look into options to use my linux device to turn on the projector.
@helgek Success!!! Using exactly your command(except for manufacturer data), I am now able to power on the projector from my raspberrypi, it seems replicable for now, need more times to verify.
@manymuch So great to hear this!! I think with my Intel NUC integrated bluetooth adapter it's not this reliable or maybe it has something to do with the Bluez version or something else 🤷 I'm looking forward to more updates from you when you have completed more testing! It's so nice to see that this BLE topic gains pace now, will also interesting to see if this might also find its way into Home Assistant's recent Bluetooth implementation efforts
@manymuch btw, I never found this XGIMI app that you mentioned in your initial post. Maybe it could provide additional insights into BLE commands being exchanged/sent between remote and projector.
additional note: I also added your finding to the Stackoverflow thread
Update: I have implemented the poweron command into the xgimi integration. The ble advertisement is based on bluez-peripheral. The new integration has been released as v0.0.2
The poweron is not very stable but work in most of the time as I tested.
@helgek to answer your questions:
Hi. I found the wakeup code for XGIMI Horizon pro 4K.
Company ID:0x0046 Data:0x1A7E0C743AEF18FFFFFF3043524B544D
On a diffarent way, is it possible to use the HDMI CEC signal as a more reliable power-on signal than BLE? https://www.home-assistant.io/integrations/hdmi_cec/ https://github.com/ideaChenGo/esp-cec
@uni-uni-77 Of course, but HDMI CEC is not suitable for everyone and also requires additional hardware. Besides, my XGIMI z6x does not support HDMI CEC :(
@manymuch thanks a lot for your integration update and the interesting insights you provided! In addition: I can't thank you enough for providing these UDP commands in your integration! I was about to try to run a a bluetooth keyboard emulation on my Intel NUC device which would have been a far less preferable option for several reasons. I will try your integration later and let you know how it works for me. Regarding reliability I had also mixed experience with Bluez but I can't tell if the issues are related to Bluez or the BLE adapter. Hopefully it will become clearer by the time, maybe also with more users sharing their experience. I've e.g. had the impression that Bluez would sometimes not stop advertising even though I had sent the stop command. Similar experience I also had at least once with the Bluetooth Smart Scanner App on my Android device. So possibly the issues are more software-related than hardware-related.
Maybe an idea which could help to increase reliability: Maybe one could check the power on status of the projector in your integration and repeat the BLE advertisement until a positive response.
Hi. I found the wakeup code for XGIMI Horizon pro 4K.
Company ID:0x0046 Data:0x1A7E0C743AEF18FFFFFF3043524B544D
On a diffarent way, is it possible to use the HDMI CEC signal as a more reliable power-on signal than BLE? https://www.home-assistant.io/integrations/hdmi_cec/ https://github.com/ideaChenGo/esp-cec
@uni-uni-77 thank you for sharing your findings! I updated the [Stackoverflow thread] (https://stackoverflow.com/questions/69921353/how-can-i-clone-a-non-paired-ble-signal-from-a-remote-to-trigger-a-device/75551013#75551013) to include the information for this projector as well.
Also the information regarding existing HDMI CEC implementation projects is really interesting. My projector is connected to a soundbar which doesn't send a power on command but I'm now wondering if maybe an HDMI splitter could be used to connect the projector to an additional device which would send the power on command. For the moment in my setup I think I will be satisfied enough with the BLE advertisement solution but maybe at some point I'd also be interested to have a closer look at this alternative approach.
@helgek Hi, could you kindly provide your hardware information? I’m currently running HaOS 9.5 on a virtual machine and attempting to use an Intel 3168 Bluetooth adapter, but have encountered some errors:
[bluetooth]# advertise on
LEAdvertisingManager not found
Failed to register advertising
Would you be able to share any relevant information about your system specifications? Thank you.
Is there anyone tried to use ESP32 as ble server to broadcase the power on signal?
@giuem bluetoothctl seems to be quite buggy and unstable from what I've experienced so far. I had similar errors and often it helped to simply restart the system. I think for the moment if one seeks for a stable advertisement solution an ESP32 based solution as just mentioned by sasukebinbin could be the more reliable approach. Alternatively you could look into using the older hcitool commands which work with older bluetooth dongles (as outlined in my previous post ). I added one such older BLE4.0 dongle to my Intel NUC setup but I haven't found time yet to run more tests. Find more info e.g. here and here.
My Intel NUC is this one. The bluetooth adapter is this according to lsusb: Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
@sasukebinbin Here is the a reference using esphome to send ble advertisement.
@sasukebinbin Here is the a reference using esphome to send ble advertisement.
Thanks for the reference. But it's a bit difficult to understand. Cause I think he is just giving an example on using 2 ESP32 to run as Client and Server. But actually we just need a Server to advertise. Not good at C++... Anyone can help to give an example on create a button and when press the button then set manufacturer data and advertising.
The hardcoded manufacturer code doesn't work at all on my xgimi H3 projector with mainland China firmware. So I guess I might need another one?
I just captured the BLE poweron event, I get this data:
and I have changed the yaml code accordingly, but no luck, still no poweron. remote:
@netweaver1970 for initial validation if power on works for your projector using the manufacturer data you captured I suggest using an android device with EFR Connect. The required settings in this app can be found here. Once this has hopefully worked out successfully there will be a better starting point to look into the BLE power on integration from manymuch and investigate potential reasons why you haven’t been successful with it .
That's true, if no luck with integration directly, try step by step verification
@netweaver1970 for initial validation if power on works for your projector using the manufacturer data you captured I suggest using an android device with EFR Connect. The required settings in this app can be found here. Once this has hopefully worked out successfully there will be a better starting point to look into the BLE power on integration from manymuch and investigate potential reasons why you haven’t been successful with it .
Very good news, I hadn't noticed that the xgimi integration had actually created a 2nd remote entity in HA (remote.h3_2), with the same Name and left the 1st one orphan. This happened most likely after modifying the configuration.yaml with the newly found token.
When sending the 'poweron' command to the 2nd one, all worked file, as well as the 'poweroff'. This allows my previous VERY MacGyver setup to be decommissioned, being a ESP12 controlled dual relay module, running ESPhome, connected to a hacked physical Xgimi remote to short the power button... This was at best workable but sometimes finicky due to different behaviour depending on playing or non-play state of the projector, needing long or short press.
The combined Bluetooth/UDP solution is much cleaner and way more reliable. Thanks for all the effort put in on all sides to get this working!
So I can confirm the token D1497DBDA42360FFFFFF3043524B544D is working fine for the H3 model, it can be added to the tried and tested list.
@netweaver1970 Thanks for the update and congratulations on the successful outcome! I added your information to the list of working parameters.
I can confirm that token 143FCB9335F278FFFFFF3043524B544D
worked to power on Xgimi Halo+. However no other commands seem to work.
Someone got the token for Elfin projector?
@facutopa yes, everything’s available in this thread
@helgek I tried but I can't make it work. I read and found what you mentioned but I don't know if I put the correct token:
Advertising Data XGIMI Elfin projector:
Flags: GeneralDiscoverable, [Device specific] Manufacturer data: 0×0046 0x12D7C7899B9F80FFFFFF3043524B544D Service UUID: 0x1812
Is this the token "12D7C7899B9F80FFFFFF3043524B544D"?
@facutopa did you try with EFR Connect ? 12D7C7899B9F80FFFFFF3043524B544D is the right token. It's also not likely that there exist other tokens since this token is hard-coded into the Elfin remote (as far as we know). You could also double check with your remote control and this iOS BLE scanner app: https://apps.apple.com/us/app/bluetooth-smart-scanner/id509978131
ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [4564053888] [Errno 2] No such file or directory
Traceback (most recent call last):
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
await hass.services.async_call(
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/core.py", line 1849, in async_call
task.result()
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/core.py", line 1889, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/helpers/entity_component.py", line 226, in handle_service
await service.entity_service_call(
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/helpers/service.py", line 798, in entity_service_call
future.result() # pop exception if have
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 981, in async_request_call
await coro
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/homeassistant/helpers/service.py", line 838, in _handle_entity_call
await result
File "/Users/me/.homeassistant/custom_components/xgimi/remote.py", line 97, in async_send_command
await self.xgimi_api.async_send_command(single_command)
File "/Users/me/.homeassistant/custom_components/xgimi/pyxgimi.py", line 96, in async_send_command
await self.async_robust_ble_power_on(self.manufacturer_data)
File "/Users/me/.homeassistant/custom_components/xgimi/pyxgimi.py", line 79, in async_robust_ble_power_on
await self.async_ble_power_on(manufacturer_data, company_id, service_uuid)
File "/Users/me/.homeassistant/custom_components/xgimi/pyxgimi.py", line 66, in async_ble_power_on
bus = await get_message_bus()
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/bluez_peripheral/util.py", line 37, in get_message_bus
return await MessageBus(bus_type=BusType.SYSTEM).connect()
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
super().__init__(bus_address, bus_type, ProxyObject)
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/dbus_next/message_bus.py", line 85, in __init__
self._setup_socket()
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
raise err
File "/Users/me/.pyenv/versions/3.10.11/envs/hass/lib/python3.10/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory
请问发送poweron 命令报这个错 是什么原因 版本v0.0.5 设备 h3 tpken: D1497DBDA42360FFFFFF3043524B544D 蓝牙设备: macmini 自带蓝牙
感谢作者,我用的投影也是是Z6X,集成后除开机一切正常。根据使用说明我这台设备的token是13676c6b951350ffffff3043524b544d,通过在树莓派上使用bluetoothctl测试可以开机,但当我调用poweron服务时报以下错误。根据检索初步怀疑是HA版本导致的,但解决方法没有头绪,python不熟悉。我使用的HA版本是:2023.3.2
ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547530116832] Error handling message: Unknown error (unknown_error) J from 192.168.123.18 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 647, in handle_execute_script
await script_obj.async_run(msg.get("variables"), context=context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 961, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 726, in _handle_entity_call
await result
File "/config/custom_components/xgimi/remote.py", line 97, in async_send_command
await self.xgimi_api.async_send_command(single_command)
File "/config/custom_components/xgimi/pyxgimi.py", line 96, in async_send_command
await self.async_robust_ble_power_on(self.manufacturer_data)
File "/config/custom_components/xgimi/pyxgimi.py", line 79, in async_robust_ble_power_on
await self.async_ble_power_on(manufacturer_data, company_id, service_uuid)
File "/config/custom_components/xgimi/pyxgimi.py", line 66, in async_ble_power_on
bus = await get_message_bus()
File "/usr/local/lib/python3.10/site-packages/bluez_peripheral/util.py", line 37, in get_message_bus
return await MessageBus(bus_type=BusType.SYSTEM).connect()
File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
super().__init__(bus_address, bus_type, ProxyObject)
File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 85, in __init__
self._setup_socket()
File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
raise err
File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory
@Johnny-Liang see https://github.com/manymuch/Xgimi-4-Home-Assistant/issues/12 if you are using HA docker installation.
I've been trying to sniff the codes for the xgimi z4 aurora but I dont seem to be having much luck, I can see the manufacturer data being sent, but when I try replay it nothing happens on the projector :(
@ouchkilljoys maybe you're in the same situation like Muxa: https://stackoverflow.com/a/75563140 He had to add Scan Response data to make his Xgimi Halo+ turn on. I don't know if you will be able to sniff Scan Response data with EFR Connect. If not you may need a more professional bluetooth sniffer device like nRF52840 together with nRF Connect for Desktop Bluetooth Low Energy App. It's not to expensive and I had similarly good experience like with the much more expensive ubertooth stick.
I hope this helps. If you've been successful please share your information so that we can add it to the list of working devices.
Just managed to turn on my XGimi H5 projector with code: 0x4d4b17d86c27e0ffffff3043524b544d
@rabdalov Congratulations and thank you for sharing the code! I will add it to the list of working codes: https://stackoverflow.com/questions/69921353/how-can-i-clone-a-non-paired-ble-signal-from-a-remote-to-trigger-a-device/
@ouchkilljoys maybe you're in the same situation like Muxa: https://stackoverflow.com/a/75563140 He had to add Scan Response data to make his Xgimi Halo+ turn on. I don't know if you will be able to sniff Scan Response data with EFR Connect. If not you may need a more professional bluetooth sniffer device like nRF52840 together with nRF Connect for Desktop Bluetooth Low Energy App. It's not to expensive and I had similarly good experience like with the much more expensive ubertooth stick.
I hope this helps. If you've been successful please share your information so that we can add it to the list of working devices.
I tried out the nRF52840 with Wireshark but I dont see any scan response data and the manufacturer data im sending looks correct but the projector just doesnt respond :(
Has anyone studied Hisense c1 laser projector?
@ouchkilljoys maybe you're in the same situation like Muxa: https://stackoverflow.com/a/75563140 He had to add Scan Response data to make his Xgimi Halo+ turn on. I don't know if you will be able to sniff Scan Response data with EFR Connect. If not you may need a more professional bluetooth sniffer device like nRF52840 together with nRF Connect for Desktop Bluetooth Low Energy App. It's not to expensive and I had similarly good experience like with the much more expensive ubertooth stick. I hope this helps. If you've been successful please share your information so that we can add it to the list of working devices.
I tried out the nRF52840 with Wireshark but I dont see any scan response data and the manufacturer data im sending looks correct but the projector just doesnt respond :(
Can you maybe share a screenshot of your EFR Connect settings. Like this we could at least validate those settings. Please feel free to also share your Wireshark findings. Muxa might also be able to further support.
@ouchkilljoys maybe you're in the same situation like Muxa: https://stackoverflow.com/a/75563140 He had to add Scan Response data to make his Xgimi Halo+ turn on. I don't know if you will be able to sniff Scan Response data with EFR Connect. If not you may need a more professional bluetooth sniffer device like nRF52840 together with nRF Connect for Desktop Bluetooth Low Energy App. It's not to expensive and I had similarly good experience like with the much more expensive ubertooth stick. I hope this helps. If you've been successful please share your information so that we can add it to the list of working devices.
I tried out the nRF52840 with Wireshark but I dont see any scan response data and the manufacturer data im sending looks correct but the projector just doesnt respond :(
Can you maybe share a screenshot of your EFR Connect settings. Like this we could at least validate those settings. Please feel free to also share your Wireshark findings. Muxa might also be able to further support.
I seemed to also get this one
Then my app config, I tried both codes listed above
Hi, about the EFR Connect One time we setup this: What is supposed to be done? Turn off the projector and see if something happened in the app? I tried, I thought I setup correctly with the token associated to my projector but nothing happened.
@ouchkilljoys sorry I didn't come back on this yet. I just had and have to many things on the table at the moment but I will try to follow-up later. @muxa The Xgimi Z4 Aurora might have similar additional challenges regarding BLE advertising like Xgimi Halo+ . Do you maybe have additional suggestions for ouchkilljoys regarding how he could further investigate the BLE signal coming from the Z4 Aurora remote control since only using manufacturer code doesn't seem to work. Thanks!
With the release of 2022.8.0 that includes bluetooth control is there a way we can get this to work with Xgimi?