GithubHelp home page GithubHelp logo

Can't send "Press" to Bot about python-host HOT 10 OPEN

tojannaon avatar tojannaon commented on August 28, 2024 1
Can't send "Press" to Bot

from python-host.

Comments (10)

tojannaon avatar tojannaon commented on August 28, 2024 1

@reestr Sorry for not chiming in earlier. I ended up having to bail as the Switchbot folks felt that the Bluetooth LE dongle that I was using (expensive and state-of-the-art) was somehow not compatible (even though it works for other applications). I didn't have another to try and wasn't about to purchase one in case there actually were other issues causing the problem.

from python-host.

reestr avatar reestr commented on August 28, 2024

I seem to have this same issue. I've never been able to try an earlier firmware to confirm if that works, my switchbot turned up with 6.3 installed. Did you ever find a workaround for it @tojannaon ?

from python-host.

dcarrion87 avatar dcarrion87 commented on August 28, 2024

@tojannaon @reestr

Can you guys can any commands to send including on/off?

I'm on bot version 5.0 and I just get invalid handle errors from gatt.

# gatttool -t random -b XX:XX:XX:XX:XX:XX --char-write-req -a 0x0016 -n 570101
Characteristic Write Request failed: Invalid handle

# gatttool -t random -b XX:XX:XX:XX:XX:XX --char-write-req -a 0x0016 -n 570102
Characteristic Write Request failed: Invalid handle

from python-host.

dcarrion87 avatar dcarrion87 commented on August 28, 2024

@reestr try this project instead: https://github.com/Danielhiversen/pySwitchbot

I was only able to get it working through that project.

E.g.:

from switchbot import Switchbot
from bleak import BleakScanner
import asyncio

async def main():
  ble_device = await BleakScanner.find_device_by_address("MAC ADDRESS", timeout=20)
  device = Switchbot(ble_device)
  await device.press()

if __name__ == "__main__":
  asyncio.run(main())

You can also set change mode with:

await device.set_switch_mode()
await device.set_long_press(7)

from python-host.

TForest-UwU avatar TForest-UwU commented on August 28, 2024

Hello,

i have the same issue as @tojannaon, however i the software @dcarrion87 provided gives me this error

Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'switchbot'

I have cloned the git through git clone however i cant seem to find a solution to both these problems.

I am using switchbot version 6.3 and a raspberry pi 3 on the raspbian OS

from python-host.

dcarrion87 avatar dcarrion87 commented on August 28, 2024

@TForest-UwU have you:

pip install PySwitchbot

Also you'll need these pip packages too. But they should come down with that one ^

async_timeout>=4.0.1
bleak>=0.17.0
bleak-retry-connector>=2.9.0
cryptography>=38.0.3
boto3>=1.20.24
requests>=2.28.1

from python-host.

TForest-UwU avatar TForest-UwU commented on August 28, 2024

Yes i retried it and it seemed i also had a outdated pip installation, however the program fails to build cryptography with this error

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for cryptography Failed to build cryptography ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects

the rest of the packages seem to all have installed correctly

from python-host.

dcarrion87 avatar dcarrion87 commented on August 28, 2024

Create a virtual environment first and work in there so you don't mess with your system wide pip packages.

python -m venv venv
. venv/bin/activate

Then do your pip things.

You might need to do some googling of that error to make sure you have build-essentials, upgrade pip version, downgrade setuptools if necessary etc... (I've not be doing this from raspbian).

Maybe apt-get install build-essentials and a pip3 install --upgrade pip might get you going.

from python-host.

TForest-UwU avatar TForest-UwU commented on August 28, 2024

If anyone is still having issues check out https://github.com/TForest-UwU/Switchy

I found out that atleast for me this api does not send the command properly, but it does connect nicely.
I then found another api that does the exact opposite, so i combined then into a working program

from python-host.

reestr avatar reestr commented on August 28, 2024

@TForest-UwU - thank you for following up with this, despite reporting an error after each press of the switch, it works as expected! :-)

from python-host.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.