Pet Feeder

A pet feeder is a device whose deviceType is DeviceType.PET_FEEDER.value ("PetFeeder"). It dispenses food on schedules, on demand (Feed Now) and from its physical button. Feeder calls are on InstaVision.deviceServices, except the feeding history, which is on InstaVision.eventServices.

Calls that take a Device wake the feeder first (WakeUpReason.ChangeSettings); a failed wake-up goes to onError and sends no request. Calls that take spaceId / deviceId leave it asleep.

Pre-requisite: The user has to be signed in to perform the following operations.


Schedules

A FeederSchedule has an id, name, enabled, days (WeekDay.values, 1 = Sunday … 7 = Saturday), hour (0–23), minute (0–59), amount, unit (always "Portion", FEEDER_PORTION_UNIT) and mealCall (play the meal call before dispensing).

Get the schedules

InstaVision.deviceServices.getFeederSchedules(
  spaceId = "spaceId",
  deviceId = "deviceId",
  onSuccess = { feederSchedules ->
    // FeederSchedules: enabled (whether the feeder runs schedules at all) and schedules
  },
  onError = { error -> }
)

Create or update a schedule

Both take a FeederScheduleRequest; updateFeederSchedule replaces the whole schedule.

val request = FeederScheduleRequest(
  name = "Breakfast",
  enabled = true,
  days = listOf(WeekDay.MONDAY.value, WeekDay.FRIDAY.value),
  hour = 8,
  minute = 0,
  amount = 2,
  mealCall = true,
)
InstaVision.deviceServices.createFeederSchedule(
  device = device,
  request = request,
  onSuccess = { schedule -> /* The created FeederSchedule */ },
  onError = { error -> }
)
InstaVision.deviceServices.updateFeederSchedule(
  device = device,
  scheduleId = "scheduleId",
  request = request,
  onSuccess = { schedule -> /* The updated FeederSchedule */ },
  onError = { error -> }
)

Delete schedules

Removes several schedules in one call.

InstaVision.deviceServices.deleteFeederSchedules(
  device = device,
  scheduleIds = listOf("scheduleId1", "scheduleId2"),
  onSuccess = { },
  onError = { error -> }
)

Feed Now and meal call

InstaVision.deviceServices.feedNow(
  device = device,
  request = FeedNowRequest(amount = 1, mealCall = false),
  onSuccess = { result -> /* FeedNowResult.manualFeedId */ },
  onError = { error -> }
)

InstaVision.deviceServices.mealCall(
  device = device,
  onSuccess = { /* The feeder played its recorded meal call */ },
  onError = { error -> }
)

Feeding records

One page of the feeder’s dispenses fed after from (epoch millis), newest first. Pass the number of records already loaded as skip to get the next page.

InstaVision.eventServices.getFeedingRecords(
  spaceId = "spaceId",
  deviceId = "deviceId",
  from = 0L,
  skip = 0L,
  onSuccess = { page ->
    // PaginatedResponse<FeedingRecord>: items and totalCount
  },
  onError = { error -> }
)

A FeedingRecord carries mode (FeedingMode: Scheduled, Manual, PhysicalButton, or Unknown), scheduleId (for scheduled feeds), portions, unit, result (FeedingResult: Success, Failed, or Unknown), exceptions and fedAt. exceptions lists ErrorCodes: FOOD_JAM, NO_FOOD, LOW_FOOD, LOW_BATTERY, MOTOR_FAILURE, with FEEDER_UNKNOWN for any other code.


Desiccant

The feeder tracks when its desiccant pack was last replaced. Both calls return a FeederDesiccant with lastReplacedAt, nextDueAt (epoch millis), daysLeft and due, all nullable.

InstaVision.deviceServices.getFeederDesiccant(
  spaceId = "spaceId",
  deviceId = "deviceId",
  onSuccess = { desiccant -> },
  onError = { error -> }
)

// After the user replaces the desiccant
InstaVision.deviceServices.resetFeederDesiccant(
  spaceId = "spaceId",
  deviceId = "deviceId",
  onSuccess = { desiccant -> /* The restarted cycle */ },
  onError = { error -> }
)

Notifications

Feeder alerts are muted through Notification.feederNotification (FeederNotification): petMissingMute, foodJamMute, lowFoodMute, lowBatteryMute, foodDispensedMute and desiccantReminderMute. A null switch is left out of the write and stays unchanged.

InstaVision.deviceServices.updateNotificationSettings(
  device = device,
  request = Notification(feederNotification = FeederNotification(lowFoodMute = true)),
  onSuccess = { },
  onError = { error -> }
)

This site uses Just the Docs, a documentation theme for Jekyll.