MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / getNextDeviceEvents

Function getNextDeviceEvents

src/lib/command/util/history.ts:31–51  ·  view source on GitHub ↗
(
		table: Table,
		items: DeviceActivity[],
		options: Partial<DeviceActivityOptions>,
)

Source from the content-addressed store, hash-verified

29export const sortEvents = (list: DeviceActivity[]): DeviceActivity[] => list.sort((a, b) => b.epoch - a.epoch)
30
31export const getNextDeviceEvents = (
32 table: Table,
33 items: DeviceActivity[],
34 options: Partial<DeviceActivityOptions>,
35): void => {
36 for (const item of items) {
37 const date = new Date(item.time)
38 const value = JSON.stringify(item.value)
39 const row = [
40 options.utcTimeFormat ? date.toISOString() : date.toLocaleString(),
41 item.component,
42 item.capability,
43 item.attribute,
44 item.unit ? `${value} ${item.unit}` : value,
45 ]
46 if (options.includeName) {
47 row.splice(1, 0, item.deviceName)
48 }
49 table.push(row)
50 }
51}
52
53export const writeDeviceEventsTable = async (
54 command: SmartThingsCommand,

Callers 2

writeDeviceEventsTableFunction · 0.85
history.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected