Roman Mitnitski
Dec 29, 2018

Python API and long press


Found the python api implementation in GitHub, and it works fine for simple presses


I am looking for an API for long press (this is how I can arm my home alarm). Python API does not seem to expose the length of key press. There is, though, an option for "On" and "Off" commands, but I can't see any difference in what the bot does when I execute those commands (it just does the simple press).


Can anyone here advise?

Jan 7

Hi please set the long press duration in your App then use the API to control your bot.


The long press setting is applied in every action.

Roman Mitnitski
Jan 7

Ah, but see, I use same bot to punch in the security code (lets say, "arm the alarm" in my system is long press on "1", but to disarm I need to punch in code (lets say 179) - which needs a SHORT press on "1" (and yes, I have two more bots pressing "7" and "9" :-). Disarming part works great with python (I just connect to all the bots and issue press commands). If I configure the long press on "1" from the app it breaks the disarm flow. And no, I don't have space to fit two bots around "1". And can't reconfigure alarm pad functionality.... So I need the long press thing. I don't believe it's THAT hard to do, it's just that part of Bluetooth interface is sadly not exposed.

Jan 14

@Roman Mitnitski Hey, sorry, the firmware is designed with a fixed long press parameter so we do not have a Bluetooth interface to implement this...

Roman Mitnitski
Jan 11

Just wanted to share the fact that I finally made it work. The short story is that github code has "on" and "off" codes to transmit to the bot, but like I said the codes were just "pressing" the button.


Don't know what exactly is the intention of the programmer, but when I changed the 'on' command from

'\x57\x01\x01' to '\x57\x01\x03', the robot worked as intended (that is, the lever came out and stayed out until I transmitted the "off" command ('\x57\x01\x02'). So now, with a wait between on and off I can do long keypress... Yay!

Jan 14

Fantastic!!! Great to know that... The on/off command is designed for the light switch mode... lol

New Posts
  • Lee TY
    a day ago

    Hi,there. I'm doubted that even this writings are written on your post :) On the feedback messanger, you guys asked me to upload my firmware info on my app and devices. And I sent you and waited for 4 days(2days if counting business days). Today, I got the message I didnt reply anything. Wow.... A week ago, I firstly post that your device doesn't recognize the basic timer and the things I've been replied are what is your firmware version? and ignoring messages...
  • Thierry Delabre
    3 days ago

    La télécommande freebox semble être une telecommande radio et non IR. Impossible de l’ajouter au hub ??
  • polar_moose
    5 days ago

    Was working until it tried to update firmware. Now it doesn't even light up. Have another hub that updated and works fine. When I go through the process, after turning from Auto to on it displays a white rectangle box with a blue dot with three dots in it. The bottom says start adding and it freezes there. Bluetooth is on, 2.4 network, and location premission given. Tried cord for working hub and no change. Cleared cache. Finally after freezing it adds a box to the home page with all my hubs and meters That say hub bootloader EC and if I click it it it says unable to connect, move closer. I pressed the reset button on the hub for about ten seconds while in the on position. Help.

About us

SwitchBot is your simple switch to a smart home. With easy set-up, we help you to create a comfortable home with innovative smart home products.

We believe a smart home should be simple and comfortable. With the mission of making your life simpler in the most accessible way, SwitchBot is dedicated to creating and crafting the most innovative smart home products for you.


Subscribe to our email, follow us on social media, so you could get the best smart home product updates as soon as we have one.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
© 2019 By Wonderlabs, Inc.