brianpeiris / switchmate

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

Switchmate firmware update broke this script! #6

Closed armaanbindra closed 6 years ago

armaanbindra commented 6 years ago

Switchmate firmware update broke this script! After a recent firmware update switchmate pushed out, I can no longer use this script to discover and connect to it. Please help, if somebody has figured out how to make it work with the new firmware update, this was integral to my smarthome setup :(

brahmafear commented 6 years ago

iOS app v 3.2.0 available. Applies 2.99.18 to 'original' device. Results of testing look good. I am able to use the most recent commit to master branch to control switchmate from rPi3.

I am getting a bunch of exceptions which might be due to switchmate being slightly out of range:

$ sudo ./switchmate.py status Looking for switchmate status... {redacted MAC} on Traceback (most recent call last): File "./switchmate.py", line 183, in status(arguments['']) File "./switchmate.py", line 131, in status scanner.stop() File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 630, in stop self._mgmtCmd(self._cmd()+"end") File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 272, in _mgmtCmd rsp = self._waitResp('mgmt') File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 326, in _waitResp raise BTLEException(BTLEException.DISCONNECTED, "Device disconnected") bluepy.btle.BTLEException: Device disconnected

$ sudo ./switchmate.py {redacted MAC} none switch off Traceback (most recent call last): File "./switchmate.py", line 186, in device = Peripheral(arguments[''], ADDR_TYPE_RANDOM) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 353, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 402, in _connect "Failed to connect to peripheral %s, addr type: %s" % (addr, addrType)) bluepy.btle.BTLEException: Failed to connect to peripheral {redacted MAC}, addr type: random

Can we catch these exceptions and print message instead of erroring-out?

New debug command successfully prints out a bunch of info.

Let me know any more tests you'd like me to run on original unit.

Thanks to all for the work and collaboration on getting this to work!

brianpeiris commented 6 years ago

👍 Thanks for testing things out. I've updated master with #7 to deal with the exception cases.

rjcooper725 commented 6 years ago

Hello,

I might be better off just waiting for the public API but it never hurts to ask.

I create tech for very disabled people. Have done this since 1983 (not a typo ;-) !

Working on an iOS app that would let a severely challenged person control appliances (lights and other AC devices) in their environment, to create independence for some, and learning for others.

I wish to use the Switchmate dual AC outlet and the SwitchMate lightswitch, the ones that are so simple to plug-in/stick-on.

I only wish to have control over off/on via Bluetooth, if possible, from iOS.

I'm using an older authoring/rapid-development tool, Director from Adobe (discontinued), that serves my purpose very well for iOS development. I have a programmer that can create 'externals' that I can call from Director to API's/libraries.

Should I just wait?

Thanks!

RJ :)

-- RJ Cooper, M.Ed.- ASD Special Needs Technology Developer/Specialist 1-800-RJCooper http://rjcooper.com

Please 'Like' me on Facebook: http://facebook.com/rjcooperinc

brianpeiris commented 6 years ago

@rjcooper725 If you don't want to wait, have your programmer take a look at this project, written in Swift for macOS https://github.com/scottjg/switchmate. He might be able to create an "external" from that, though he'll probably have to update it to work with the latest firmware. That should be easy enough by following the python code in this project. Good luck!

rjcooper725 commented 6 years ago

Thanks, Brian! I'm having him take a peek.

:)

-------- Forwarded Message -------- Subject: Re: [brianpeiris/switchmate] Switchmate firmware update broke this script! (#6) Date: Mon, 19 Feb 2018 12:03:27 -0800 From: Brian Peiris notifications@github.com Reply-To: brianpeiris/switchmate reply@reply.github.com

To: brianpeiris/switchmate switchmate@noreply.github.com CC: rjcooper725 rj@rjcooper.com, Mention mention@noreply.github.com

@rjcooper725 https://github.com/rjcooper725 If you don't want to wait, have your programmer take a look at this project, written in Swift for macOS https://github.com/scottjg/switchmate. He might be able to create an "external" from that, though he'll probably have to update it to work with the latest firmware. That should be easy enough by following the python code in this project. Good luck!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/brianpeiris/switchmate/issues/6#issuecomment-366790717, or mute the thread https://github.com/notifications/unsubscribe-auth/AeEFPvGZJch1LZLmjkJ0hBn4pF2Tqgmiks5tWdOPgaJpZM4Pz51-.

tateu commented 6 years ago

Ahh...I decided to upgrade one of my RSM001W devices to the newest firmware, 2.99.18, and it doesn't work like it used to.

With the original firmware I was able to add a third switch command so it was

# switch [on | toggle | off]
if arguments['on']:
        val = '\x01'
    elif arguments['toggle']:
        val = '\x02'
    else:
        val = '\x00'

where toggle would set the device to the opposite of whatever it is currently set at. I need this because I am using one Switchmate on a 3 way light switch. This sucks because now I cannot go back to older firmware.

I need this feature back.

valkjsaaa commented 6 years ago

So you mean it can it can turn on and off, but not toggle with that command?

valkjsaaa commented 6 years ago

Also, is the latest firmware similar to the orignal firmware which requires a auth for it to work or similar to the newer firmware which requires no auth field and just works by writing 0 or 1 to a specific characteristic?

tateu commented 6 years ago

Yes, on = '\x01' and off = '\x00' work but toggle = '\x02,' that I used in my modified version, no longer works. The RSM001W on the newest firmware, 2.99.18, works with no auth.

rjcooper725 commented 6 years ago

Hi to all, especially CRAIG!

I was at OSH (Orchard Supply Hardware) today to get a drill bit and came across a display of yours, which made me happy. But, your stuff was on clearance, usually meaning they're not going to restock. They were selling the motorized light switch for $9! I asked a sales person and he seemed pretty knowledgeable and claimed it didn't sell so they weren't getting any more :-( But, in your defense, he claimed none of the smarthome stuff sells; they don't even carry any smartbulbs.

But it makes me a bit nervous that you lost Wink and now OSH :-( You can go to the OSH site and see the clearance price and that they've dropped it from the online store :-( http://www.osh.com/search?text=switchmate&source=osh

Thought you'd want to know ;-)

RJ :-)

-- RJ Cooper, M.Ed.- ASD Special Needs Technology Developer/Specialist 1-800-RJCooper http://rjcooper.com

Please 'Like' me on Facebook: http://facebook.com/rjcooperinc

brianpeiris commented 6 years ago

@tateu I could add a "toggle" command to the python script that just checks the current state of the switch and switches it to the opposite.

But please let's try to keep this particular issue on topic. Feel free to open a new issue if you want to discuss something else.

brianpeiris commented 6 years ago

Just got the updated Android app and upgraded the firmware on my Original and my recently purchased Bright devices. Confirmed that the new firmware works without auth as expected!

Thank you all for the discussion in this issue. I think we can finally call it closed!