dnschneid / pysmartblinds Goto Github PK
View Code? Open in Web Editor NEWPython interface to BLE-based MySmartBlinds
License: Apache License 2.0
Python interface to BLE-based MySmartBlinds
License: Apache License 2.0
My blinds are running MCU 2.1. Has anyone confirmed whether or not this library will work? search.py did not work for me, but (I think) I got my passkey using the Android Bluetooth snoop log and Wireshark. Using that passkey and MAC, httpserver.py throws the following error when I try to GET /pos:
`
Am I just out of luck with 2.1, or am I doing something else wrong? Happy to help try to develop 2.1 support if possible.
After restarting, subsequently I'm getting these errors:
WARNING (MainThread) [homeassistant.components.cover] Setup of cover platform mysmartblinds is taking over 10 seconds.
Logger: pygatt.backends.gatttool.gatttool
Source: /usr/local/lib/python3.8/site-packages/pygatt/backends/gatttool/gatttool.py:387
ERROR (SyncWorker_3) [pygatt.backends.gatttool.gatttool] Timed out connecting to F4:6D:E5:54:1B:8D after 5.0 seconds.
Is this message because my keys are wrong? Or is it something else. I used an android phone to get them. I also have Ian Levasque Mysmartblinds Bridge client installed, but don't know how to get the keys with that?
(I also had to change the folder naming a little bit to install it. In custom components, I now have a folder named mysmartblinds and renamed the file mysmartblinds.py to cover.py. Also changed CoverDevice to CoverEntity since that was deprecated.)
When I attempted to dump out Bluetooth HCI logs, my bug report zip didn't contain any bluetooth logs... After referring to this answer on stackoverflow (https://stackoverflow.com/a/30352487/2288993) that suggests google is moving away from providing that file, I was able to extract the bluetooth log data with the following steps:
unzip bugreport.zip bugreport*.txt
curl "https://android.googlesource.com/platform/system/bt/+/master/tools/scripts/btsnooz.py?format=TEXT" | base64 -D - > btsnooz.py
python btsnooz.py bugreport-*.txt > btsnoop_hci.log
When I run strings on that, I get my phone model number and a bunch of "SmartBlind_DFU", so I believe it captured something.
However, when I run extractkeys.py on the data, I get no output. extractkeys.py does run as it complains if I don't provide the log file as arg.
Any suggestions as to how I might be able to extract the keys? Is the mac perhaps printed on the unit somewhere? (I haven't taken one down to look).
This is awesome, thank you so much for all your hard work on this. This is a tremendous help and the thought of getting my blinds to work with homekit is very exciting. I was wondering if you have any thoughts on creating a homebridge plugin for this?
Ideally the library would be able to query the current position and battery/charging info from the blinds. This could be used to refresh the local position (in case of external adjustment) as well as provide battery warnings or whatever.
First place to check is 0x0013 (00001404-1212-efde-1600-785feabcd123)
Getting the following error:
Platform error cover.mysmartblinds - No module named 'custom_components.mysmartblinds.cover'
7:40:47 – Hass.io (ERROR)
(have yet to apply cover.patch to my homeAssistant install, because I don't know how yet...)
Looks like it's possible?
https://github.com/ianlevesque/smartblinds-client
Might want to see if you can get them to fork in some of their code. Always good to have options? Or maybe try one and fall back to the other?
The hcitool lescan part works and it is correctly identifying my Mac address for my smart blind. (Based on what I can see in hcitool and the name being presented) I have the blind very close to the pi (less than a meter) and I have tried upping the number of attempts. No dice. I also disconnected my bridge and verified that the IOS app still works. The blind I am trying to connect to works flawlessly with the IOS app. battery is at 100% (and solar charging).
Where to go from here? Happy to run some tests on my pi to try and get more data. I don't have an android phone or special LE sniffer though :/
Like I specified before I was able to control the blind through the hub via another library. Looking through what the api provides this is what I can see so far:
[Blind(name='Living Room',encoded_mac='gxxxxx7+',room_id='6xxxxxxx-0xxx-4xxx-axxx-2xxxxxxxxxx'), Blind(name='Big Window',encoded_mac='gxxxxx7+',room_id='6xxxxxxx-0xxx-4xxx-axxx-2xxxxxxxxxx'), Blind(name='Balcony Door',encoded_mac='rxxxxxxr',room_id='6xxxxxxx-0xxx-4xxx-axxx-2xxxxxxxxxx)]
{'rxxxxxxr': BlindState(position=-1,rssi=0,battery_level=-1), 'gxxxxx7+': BlindState(position=-1,rssi=0,battery_level=-1)}
(Note: The position, rssi, and battery level are not 0 or -1 when the bridge is on and connected to the blinds)
Not sure if any of that helps,
Getting this error when adding pysmartblinds.py to Hass through pyscript.
Logboekdetails (ERROR)
Logger: custom_components.pyscript.file.pysmartblinds
Source: custom_components/pyscript/init.py:227
Integration: Pyscript Python scripting (documentation, issues)
First occurred: 15:42:45 (1 occurrences)
Last logged: 15:42:45
Exception in </config/pyscript/pysmartblinds.py> line 34: from threading import Timer ^ ModuleNotFoundError: import from threading not allowed
In order to actuate blinds from Alexa via haaska, we need to define these methods:
def open_cover(self, **kwargs): # Alexa, turn off blind XYZ
def close_cover(self, **kwargs): # Alexa, turn on blind XYZ
Without them we get:
2018-11-28 01:18:46 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=cover, service=close_cover, service_data=entity_id=cover.north_bedroom, service_call_id=eb4ca86cf54144ebb0c9bcef82bdaa3b>
2018-11-28 01:18:46 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event alexa_smart_home[L]: request=namespace=Alexa.PowerController, name=TurnOff, entity_id=cover.north_bedroom, response=namespace=Alexa, name=Response>
2018-11-28 01:18:46 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 224, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/components/cover/__init__.py", line 243, in close_cover
raise NotImplementedError()
NotImplementedError
mysmartblinds.py fails to init in HA in versions >= 0.77
The SERVICE_TO_METHOD symbol was removed with this commit:
home-assistant/core@b682e48#diff-aec3f5346a76b74ad2bee24c7f56f886L76
Lines 24, 54 and 55 of examples/mysmartblinds.py reference that symbol.
If I knew what to change it to I'd submit a patch...
This was tested by dropping mysmartblinds.py into /config/custom_components/cover/ and pysmartblinds.py into /config/deps/lib/python3.6/site-packages/ on HASS.IO 0.82.1
Currently, we have this:
def open_cover_tilt(self, **kwargs):
"""Tilt the cover open. We define that as tilting down."""
self._blind.down()
This isn't consistent with how roll-down covers work... which are "on" when they roll down and block light and "off" when they roll up and let light in.
It occurs to me as I just finished writing that, that in your run through setting up the blinds, you may have chosen the tilt to be reversed for "close" than I have for mine... I'm not sure how that choice during the set-up within the app effects the blinds operation, so this setting may not be the same for you.
I've been unable to figure out how to get search.py to run on my Mac.
I'm not sure how you included the library but I used export PYTHONPATH=~/Projects/pysmartblinds/pysmartblinds/
.
After which I got the following error:
~/Projects/pysmartblinds/examples master
❯ python3 search.py
Scanning for 10 seconds...Traceback (most recent call last):
File "/Users/atlastal/Projects/pysmartblinds/pysmartblinds/pysmartblinds.py", line 45, in scan
gatt.start(reset_on_start=False)
File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 259, in start
searchwindowsize=self._search_window_size)
File "/usr/local/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 204, in __init__
self._spawn(command, args, preexec_fn, dimensions)
File "/usr/local/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
'executable: %s.' % self.command)
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: gatttool.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "search.py", line 60, in <module>
main()
File "search.py", line 49, in main
macs = scan(SCAN_SECONDS)
File "search.py", line 23, in scan
macs = pysmartblinds.scan(seconds)
File "/Users/atlastal/Projects/pysmartblinds/pysmartblinds/pysmartblinds.py", line 48, in scan
gatt.stop()
File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 281, in stop
self.disconnect(self._connected_device)
File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 53, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/pygatt/backends/gatttool/gatttool.py", line 419, in disconnect
if not self._receiver.is_set("disconnected"):
AttributeError: 'NoneType' object has no attribute 'is_set'
I'm running Python 3.7.2
Wondering if you were looking at updating this to work with the bridge instead of just Bluetooth? Also would you be able to port over to Home Assistant? It uses Python so it’s probably not too hard though I wouldn’t know where to start.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.