Help with Custom Bluetooth device integration

Hi,
I’ve been using Home assistant for a while now. Until now all my usage was simple and straight forward. This is the first time I’m trying something new.
I recently bought Lasko Bluetooth window fan. It has a phone app and is working fine. Now, I want to integrate it to Home assistant.
Using btsnoop_hci.log and Wireshark, I was able to gather the BT commands required for controlling the fan.
I need some help with connecting the fan to Pi, integrating the commands to Home assistant and control the fan through Automation.
Thanks in advance.

1 Like

Interestingly I started working on exactly same thing ( also Lasko BT Fan ) :).

Could you post the commands I mapped only On/Off so far ( same way as you btw ).

I also got it to work with pygatt maybe it will help you.

import pygatt

adapter = pygatt.GATTToolBackend()

try:
    adapter.start()
    device = adapter.connect(<MAC>)
	
	device.char_write('0000fff2-0000-1000-8000-00805f9b34fb',bytearray([4,3,4,1,8]))
	device.char_write('0000fff2-0000-1000-8000-00805f9b34fb',bytearray([4,3,4,0,7]))
	
finally:
    adapter.stop()

1 Like

Managed to do custom integration for it.

Feel free to test it. Cannot promise quick fixes but will try to review any pull request if any submitted.

Put the content in config/custom_components and add

fan:
  - platform: lasko_bt_fan_w9560
    mac: "<MAC>"

The code for discovery is ready but it is not yet tested/enabled. WIP

2 Likes

How do you add this integration?

Nvm, I missed the copying part lol

fan:
  - platform: lasko_bt_fan_w9560
    mac: "C0:B6:F9:8D:A6:26"

I cloned the repo, then copied the lasko_bt_fan_w9560 directory to my custom_components. I modified my configuration.yaml as in the above example. But validation is giving me this error

Platform error fan.lasko_bt_fan_w9560 - Integration 'lasko_bt_fan_w9560' not found.

is it a permission isssue? How can I be sure?

Arg…

I used the full path and it worked. Well a different error.

fan
  - platform: /config/custom_components/lasko_bt_fan_w9560
    mac: "C0:B6:F9:8D:A6:75"

Hi,

I developed this component 2 years ago. Lots of things changed since than in the Home Assistant.

This component used old BT stack that can be locking for new BT stack.

My Lasko fan broke so I have not really maintained this component. (Sorry)

Due to above ( both changes and lack of maintenance ) there can be lots of errors when you try to use it.

That being said creating component that would be within new guidelines based on this one should be relatively easy.

Sorry I can help more - I have no way to test it anymore.

Good luck