natekspencer / pylitterbot

Python package for controlling a Whisker connected self-cleaning litter boxes and feeders
MIT License
87 stars 11 forks source link

Question About Subscribe #227

Closed jamespauly closed 3 months ago

jamespauly commented 4 months ago

Do you have any example of how to use the account.load_robots(True). Where you are subscribing to get the updates for the robots? Just curious on how to utilize that receiver.

Thanks, James

natekspencer commented 4 months ago

The robots have an event emitter, so you can subscribe to those via something like:

from pylitterbot.robot import EVENT_UPDATE
...
robot = account.robots[0]
robot.on(EVENT_UPDATE, <some_callback>)

The Home-Assistant code uses this library so you can peruse through that on how it can be used as well https://github.com/home-assistant/core/tree/dev/homeassistant/components/litterrobot

jamespauly commented 4 months ago

Okay that makes sense I see it in the HA code. I’m trying to get this to work on the EISY on a node plugin.

Thanks much

On May 6, 2024, at 5:48 PM, Nathan Spencer @.***> wrote:

The robots have an event emitter, so you can subscribe to those via something like:

from pylitterbot.robot import EVENT_UPDATE ... robot = account.robots[0] robot.on(EVENT_UPDATE, ) The Home-Assistant code uses this library so you can peruse through that on how it can be used as well https://github.com/home-assistant/core/tree/dev/homeassistant/components/litterrobot

— Reply to this email directly, view it on GitHub https://github.com/natekspencer/pylitterbot/issues/227#issuecomment-2096981268, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLOG34UQ477MAYET4WP4X3ZA73CRAVCNFSM6AAAAABHJXLH2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWHE4DCMRWHA. You are receiving this because you authored the thread.