brianpeiris / switchmate

A python-based command line utility for controlling Switchmate switches
MIT License
35 stars 12 forks source link

Can not get my switchmate to show up at all #18

Closed roberkane212 closed 5 years ago

roberkane212 commented 5 years ago

I have a RPi 3 B+, however it seems that this is all making it where you have to use external usb BluetoothZ however I believe my RPi has internal ble

brianpeiris commented 5 years ago

Please read through this other issue that a couple of other RPi 3B+ users had a discussion in. I still don't have one myself to test with but hopefully their solution can help you as well: https://github.com/brianpeiris/switchmate/issues/15

roberkane212 commented 5 years ago

I’ve read through them, however I can even get to that part. I’m still searching to even find my device. I’ve tried all the things I’ve seen on here. If I could at least know where people are getting switchmate.py that would be great. I can’t fikd it anywhere

brianpeiris commented 5 years ago

switchmate.py is the main file in this repo: https://github.com/brianpeiris/switchmate/blob/master/switchmate.py

roberkane212 commented 5 years ago

Yes I know, I’m in it. However I get a error saying “NameError: name ‘switchmate’ is not defined

brianpeiris commented 5 years ago

Sorry, I'm not following. What steps did you take to get that error? Do you mean you modified the code in switchmate.py? Can you post the full error stack?

roberkane212 commented 5 years ago

I’m having an issue actually getting switchmate.py to scan. Can you tell me how you set up your switchmate in python. I’m sorry new to python and pip

brianpeiris commented 5 years ago

@roberkane212 Sorry, forgot to reply to this earlier. Here are some instructions:

  1. Firstly, this switchmate.py only works on Linux at the moment
  2. Download and extract the project: https://github.com/brianpeiris/switchmate/archive/master.zip
  3. In a console, run pip install -r requirements.txt
  4. Then run sudo python ./switchmate.py scan to start using the script.
roberkane212 commented 5 years ago

ok thank you i really appreciate it, can you tell me what folder the i should put in in after i download? or will it find it no matter where it is on rpi

brianpeiris commented 5 years ago

Doesn't matter where you put it, you can choose any folder. But you'll have to cd into that folder to run the above commands

roberkane212 commented 5 years ago

i got an error, could this because I'm using python 3?

$ pip3 install -r requirements.txt Collecting Django==2.1.5 (from -r requirements.txt (line 1)) Using cached https://files.pythonhosted.org/packages/36/50/078a42b4e9bedb94efd3e0278c0eb71650ed9672cdc91bd5542953bec17f/Django-2.1.5-py3-none-any.whl Collecting pkg-resources==0.0.0 (from -r requirements.txt (line 2)) Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r requirements.txt (line 2)) (from versions: ) No matching distribution found for pkg-resources==0.0.0 (from -r requirements.txt (line 2))

brianpeiris commented 5 years ago

uh. why is it trying to install django? are you sure you're in the right directory?

roberkane212 commented 5 years ago

im not sure, but i got past that. when i run sudo python ./switchmate.py scan i get this error

pi@raspberrypi:~/.homebridge/switchmate-master $ sudo python ./switchmate.py scan Traceback (most recent call last): File "./switchmate.py", line 41, in from docopt import docopt ImportError: No module named docopt

brianpeiris commented 5 years ago

That error means the requirements weren't installed

roberkane212 commented 5 years ago

they installed with no errors, i ran it just as you said

roberkane212 commented 5 years ago

~/.homebridge/switchmate-master $ pip3 install -r requirements.txt Collecting bluepy==1.2.0 (from -r requirements.txt (line 1)) Downloading https://www.piwheels.org/simple/bluepy/bluepy-1.2.0-cp35-cp35m-linux_armv7l.whl (509kB) 100% |████████████████████████████████| 512kB 522kB/s Collecting docopt==0.6.2 (from -r requirements.txt (line 2)) Using cached https://www.piwheels.org/simple/docopt/docopt-0.6.2-py2.py3-none-any.whl Collecting tabulate==0.8.2 (from -r requirements.txt (line 3)) Downloading https://files.pythonhosted.org/packages/12/c2/11d6845db5edf1295bc08b2f488cf5937806586afe42936c3f34c097ebdc/tabulate-0.8.2.tar.gz (45kB) 100% |████████████████████████████████| 51kB 1.1MB/s Building wheels for collected packages: tabulate Running setup.py bdist_wheel for tabulate ... done Stored in directory: /home/pi/.cache/pip/wheels/2a/85/33/2f6da85d5f10614cbe5a625eab3b3aebfdf43e7b857f25f829 Successfully built tabulate Installing collected packages: bluepy, docopt, tabulate Successfully installed bluepy-1.3.0 docopt-0.6.2 tabulate-0.8.2

roberkane212 commented 5 years ago

is there another command im missing?

roberkane212 commented 5 years ago

i tried to use python 3 and got this error

~/.homebridge/switchmate-master $ sudo python3 ./switchmate.py scan Traceback (most recent call last): File "./switchmate.py", line 47, in from tabulate import tabulate ImportError: No module named 'tabulate'

im very confused as it says i have both

brianpeiris commented 5 years ago

Try sudo pip3 install -r requirements.txt then sudo python3 ./switchmate.py scan

roberkane212 commented 5 years ago

it worked!!!!! now its not finding my switchman, is there anything i can do to help

~/.homebridge/switchmate-master $ sudo python3 ./switchmate.py scan Scanning... No Switchmate devices found

brianpeiris commented 5 years ago

I think we're now back to this problem: https://github.com/brianpeiris/switchmate/issues/18#issuecomment-452829499

roberkane212 commented 5 years ago

No my issue is just the discovery it says no devices found

roberkane212 commented 5 years ago

Shoukd to delete app?

brianpeiris commented 5 years ago

That's what https://github.com/brianpeiris/switchmate/issues/15 is about. RPi 3B+ requires extra setup before it can even discover devices. Please read through that thread.

roberkane212 commented 5 years ago

i can get it to toggle now, but can't get it to connect

roberkane212 commented 5 years ago

used sudo "PATH=$PATH" python3 ./switchmate.py <mac_address> toggle to see if the script can toggle your switch even if it can't scan for it. like you suggested to someone else worked for me

brianpeiris commented 5 years ago

Interesting, thanks for reporting back.

roberkane212 commented 5 years ago

i also can't get it to work with home bridge, the only way its working for me is running commands. tried to use it in cmdswitch, however the fact that you have to cd into a folder makes it too much of a command. does anyone have any advise on this issue?

brianpeiris commented 5 years ago

That might be a better question for the homebridge community

roberkane212 commented 5 years ago

anyone have a clue how i can find out my id number for my switchmate. i have everything else working

brianpeiris commented 5 years ago

Are you asking about the mac address? Maybe use an app on your phone to scan for the devices, there are a number of general bluetooth scanning apps.

roberkane212 commented 5 years ago

no the device id which i can not find in the app, nor is debug working for me. it just brings up the help options

roberkane212 commented 5 years ago

i also can not get switchman plugin to work, however all other commands work scan, status, toggle

brianpeiris commented 5 years ago

Sorry, I'm still not sure what you mean by "device id". You should only need the MAC address to use switchmate.py.

roberkane212 commented 5 years ago

im trying to add it to home bridge, do you not have your switchmate connected to home bridge?

brianpeiris commented 5 years ago

Nope, sorry, I do not use home bridge. As I mentioned, if you've got switchmate.py working in isolation, then it may be better to take this discussion to the home bridge community to answer the rest of your questions.

brianpeiris commented 5 years ago

Since homebridge is based on node.js, you might have better luck with this project instead: https://github.com/valkjsaaa/homebridge-switchmate3

roberkane212 commented 5 years ago

im forgetting about home bridge, i am not getting an error trying to run commands do you know why?

pi@raspberrypi:~/.homebridge/switchmate-master $ sudo python3 ./switchmate.py scan Scanning... Found Switchmates: c6:d6:aa:5e:bc:c6 pi@raspberrypi:~/.homebridge/switchmate-master $ sudo python3 ./switchmate.py status Looking for switchmate status... c6:d6:aa:5e:bc:c6 off pi@raspberrypi:~/.homebridge/switchmate-master $ sudo python3 ./switchmate.py c6:d6:aa:5e:bc:c6 toggle ERROR: Failed to connect to device. Try running switchmate with sudo.

brianpeiris commented 5 years ago

Hmm, I would make sure your switchmate device is updated to the latest firmware via the official switchmate app. Then try to move your switchmate closer to the RPi since that error also occurs if the bluetooth signal is weak.

roberkane212 commented 5 years ago

thanks it worked

roberkane212 commented 5 years ago

have any clue why would get this error?

pi@raspberrypi:~ $ sudo "PATH=$PATH" python3 ./switchmate.py c6:d6:aa:5e:bc:c6 toggle python3: can't open file './switchmate.py': [Errno 2] No such file or directory pi@raspberrypi:~ $

roberkane212 commented 5 years ago

Ok got all commands working, and got it working on homebridge using cmdswitch2 thanks for all your help

brianpeiris commented 5 years ago

Glad to hear it! I'll go ahead and close this issue now. If you can summarize what you did through this whole process, it may be helpful to future homebridge users.

roberkane212 commented 5 years ago

Yes it’s closed and yes I will write my steps

brianpeiris commented 5 years ago

Great, thanks!