summaryrefslogtreecommitdiffstats
path: root/tradfri-cli.nim
blob: 47abea784d4d08d0b5b63711854f60b1c73bc378 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import types, tradfri, deviceHelpers, json, os

let tradfriGateway = newTradfriGateway(
    host = "192.168.100.225",
    port = 5684,
    user = "ctucx",
    pass = "JrSGx6WkAVJUl53b"
  )


let devices = tradfriGateway.getDevices()

case paramStr(1):
of "list-devices":
  echo "list of all devices:"
  echo "======================="

  var id = 0

  for device in devices:
    echo $id & ": \tType:\t" & $device.`type`
    echo "\tName:\t" & $device.name
    echo ""
    id = id+1

of "devices-json":
  let devicesJson = %* devices
  echo devicesJson

of "devices-json-pretty":
  let devicesJson = %* devices
  echo pretty devicesJson