( table: Table, items: DeviceActivity[], options: Partial<DeviceActivityOptions>, )
| 29 | export const sortEvents = (list: DeviceActivity[]): DeviceActivity[] => list.sort((a, b) => b.epoch - a.epoch) |
| 30 | |
| 31 | export 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 | |
| 53 | export const writeDeviceEventsTable = async ( |
| 54 | command: SmartThingsCommand, |
no outgoing calls
no test coverage detected