You can display the power status of your end users' devices in your app, including whether the device is wired or battery-powered. Further, for battery-powered devices, you can also display information about the battery status, such as the battery charge level and the battery status.
To display this information, use either of the following Seam mechanisms:
Seam polls connected devices and accounts every ten minutes and updates the following device properties accordingly:
Property
Type
Description
properties.has_direct_power
Boolean
Indicates whether the device has direct power, that is, whether the device is wired
properties.battery
Object
Battery information, including level and status
If the device is offline, Seam does not return this property.
properties.battery.level
Number (0-1)
Battery level of the device as a decimal value between 0 and 1, inclusive
If the device is offline, Seam does not return this property.
properties.battery.status
Enum (string)
Current status of the battery charge level.
If the device is offline, Seam does not return this property.
Values are:
critical: Indicates an extremely low level, suggesting imminent shutdown or an urgent need for charging.
low: Signifies that the battery is under the preferred threshold and should be charged soon.
good: Denotes a satisfactory charge level, adequate for normal use without the immediate need for recharging.
full: Represents a battery that is fully charged, providing the maximum duration of usage.
Use a Get Device request to retrieve the current power status of a device. First, determine whether the device is wired. If the device is battery-powered (that is, not wired), get the battery level and status. Then, display the retrieved device power status in your app.
ID of the device for which you want to retrieve device.connected or device.disconnected events
event_type
String
Event type that you want to retrieve, that is, device.connected or device.disconnected
since
String
Desired starting event generation date and time
You must include since or between.
between
Set of two strings
Desired starting and ending event generation dates and times
For example:
["2024-01-01T00:00:00Z", "2024-02-01T00:00:00Z"]
You must include between or since.
The following example uses the List Events request to retrieve all device.battery_status_changed events for a specific device since January 1, 2024:
Request:
device_battery_status_changed_events = seam.events.list( device_id ="36cf1a96-196d-41b0-9804-88154387f1f9", event_type ="device.battery_status_changed", since ="2024-01-01T00:00:00Z")pprint(device_battery_status_changed_events)
var device_battery_status_changed_events =seam.Events.List( deviceId:"36cf1a96-196d-41b0-9804-88154387f1f9", eventType:Seam.Api.Events.ListRequest.EventTypeEnum.DeviceBatteryStatusChanged, since:"2024-01-01T00:00:00Z");foreach (var device_battery_status_changed_event in device_battery_status_changed_events){Console.WriteLine(device_battery_status_changed_event);}
var deviceBatteryStatusChangedEvents =seam.events().list(EventsListRequest.builder().deviceId("36cf1a96-196d-41b0-9804-88154387f1f9").eventType(EventsListRequestEventType.DEVICE_BATTERY_STATUS_CHANGED).since("2024-01-01T00:00:00Z").build());System.out.println(deviceBatteryStatusChangedEvents);
You can set up webhook endpoints to receive device.battery_status_changed and device.low_battery events. Then, you can use the receipt of these events to display the corresponding device status in your app. For more information about configuring webhooks, see Webhooks.