Re: [sucks-users] Python help

87 views
Skip to first unread message

William Pietri

unread,
Nov 23, 2018, 6:47:59 PM11/23/18
to Guillermo Schimmel, sucks-users
On 11/23/18 2:21 PM, Guillermo Schimmel wrote:
Hi guys

Can you please show me a little example of how should I make an event receiver for a status change?



I'm not near my vacuum so I can't easily test this, but I believe it goes something like this:

def battery_report(level):
    print(level)

vacbot.batteryEvents.subscribe(battery_report)
vacbot.run(Clean())
time.sleep(900)
That would run the vacuum for 15 minutes. Every time a battery event happens, the battery_report function gets called, and so would print out the battery level.


I know in other languages it can be harder to pass around a function. But in Python to refer to one you just give its name without the parens.

Willima

    

Guillermo Schimmel

unread,
Nov 23, 2018, 6:49:17 PM11/23/18
to William Pietri, sucks...@googlegroups.com
THANKS!!

vacbot.batteryEvents.subscribe(battery_report)

this is what I was missing.

Regards

William Pietri

unread,
Nov 23, 2018, 7:44:45 PM11/23/18
to Guillermo Schimmel, sucks...@googlegroups.com
Glad to hear it.

If you're looking for some way to contribute back, I'd say you're in an excellent position to write a first pass at a basic getting-started doc for the library. Currently we think of the library as experimental, but it's settling down such that I think we're close to a 1.0 release, at which point some docs for people in your situation would be handy.

William

Guillermo Schimmel

unread,
Nov 26, 2018, 7:53:41 AM11/26/18
to William Pietri, sucks...@googlegroups.com

Hi William.

I've been playing and with your last help this library is pure magic. I'm advancing a lot.

Just a small question, now with callbacks I have completely automated the events once the program it's running. But in order to get initial states I'm doing something like this

charge_status=vacbot.charge_status

And then I call the same callback function like charge_report(charge_status).

This it's working fine. But what I would like to know is if I'm missing some easier way of triggering all events at once.

thanks!

William Pietri

unread,
Nov 26, 2018, 9:52:40 AM11/26/18
to sucks...@googlegroups.com

Sorry, I'm not quite following this.

My recollection is that when the the VacBot object is initialized, there is no initial state. The statuses are all None. So if you subscribe to events before sending commands, you should receive all events.

If that doesn't answer your question, perhaps you could you say more about what you're up to?

William
--
You received this message because you are subscribed to the Google Groups "sucks-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sucks-users...@googlegroups.com.
To post to this group, send email to sucks...@googlegroups.com.
Visit this group at https://groups.google.com/group/sucks-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/sucks-users/CAKxvhUH%3D9cw381Ts%2BaNx7ywzwifAsne7XWQhme-ZvP5%3DOYM3zQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Guillermo Schimmel

unread,
Nov 26, 2018, 10:11:31 AM11/26/18
to William Pietri, sucks...@googlegroups.com
It's not really that important, so don't worry. 

I was under the wrong impression that the vacbot object knew the initial state of the robot. 

Not being that the case, I will just start the gateway and wait. 

It will sync the states as soon as the updates  start coming. 

Thanks 



William Pietri

unread,
Nov 26, 2018, 10:26:37 AM11/26/18
to sucks...@googlegroups.com
On 11/26/18 7:11 AM, Guillermo Schimmel wrote:

I was under the wrong impression that the vacbot object knew the initial state of the robot. 

Not being that the case, I will just start the gateway and wait. 

It will sync the states as soon as the updates  start coming.


Ah, got it. If you'd like the statuses earlier, I believe you can send the various Get commands, like GetCleanState.

William


Greg Laabs

unread,
Nov 26, 2018, 6:11:39 PM11/26/18
to sucks-users
You're definitely right that the lib features should be documented better.

Here's how initial state works: When you call connect_and_wait_until_ready, the lib will immediately try to ping the vacuum to ensure it's connected. If that succeeds, it will immediately request all of the initial states (vacuum state, battery level, and all accessory lifespans.) These calls all take some time though, so the best thing to do is simply subscribe to the updates and wait for those first ones to come in. Note that if that first ping fails to find the vacuum, it will wait 30 seconds and try again. It will do this loop forever, so if the vacuum is turned off or offline, it will get the initial states within 30 seconds of it being connected again.

Greg

Guillermo Schimmel

unread,
Nov 26, 2018, 6:30:01 PM11/26/18
to overl...@gmail.com, sucks-users
The lib is great! I have already a fully functional beta working at my system.

So I can now start to give something back in terms of my experience or documentation.

Where do you want me to start?


--
You received this message because you are subscribed to the Google Groups "sucks-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sucks-users...@googlegroups.com.
To post to this group, send email to sucks...@googlegroups.com.
Visit this group at https://groups.google.com/group/sucks-users.

Jason Arends

unread,
Dec 21, 2018, 5:37:28 PM12/21/18
to sucks-users
Sorry to reply on an old thread but I'm playing with the library and when I use the example code, after calling the connect_and_wait_until_ready, it keeps sending pings but no statuses ever get updated when the bot is just sitting fully charged. Is that expected? It seems only changes in values trigger it to update, but when I run with debugging, every ping it's sending the GetCleanState, GetChargeState, GetBatteryInfo, etc, just nothing updates.

I can send commands to get it to clean and then I start to see things coming back and battery and cleaning statuses change, but I'm not able to set those initial states before giving it a clean command.
Reply all
Reply to author
Forward
0 new messages