summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsabelle K <hi@f2k1.de>2020-09-15 13:42:50 +0200
committerIsabelle K <hi@f2k1.de>2020-09-15 13:42:50 +0200
commit42a64e209458f8833a41fafe9523dc705e0572d4 (patch)
tree934747754fdea74a86d2af9dd96d61a4e244de63
parent9687803352bc2f7c4ebff0af46c099e800f0a008 (diff)
downloadnimtradfri-42a64e209458f8833a41fafe9523dc705e0572d4.tar.gz
nimtradfri-42a64e209458f8833a41fafe9523dc705e0572d4.tar.bz2
nimtradfri-42a64e209458f8833a41fafe9523dc705e0572d4.zip
add turn-on/off
-rw-r--r--tradfriCli.nim20
1 files changed, 19 insertions, 1 deletions
diff --git a/tradfriCli.nim b/tradfriCli.nim
index 1d018a6..11dbbfd 100644
--- a/tradfriCli.nim
+++ b/tradfriCli.nim
@@ -51,6 +51,24 @@ if(paramCount() > 0):
discard devices[deviceId].togglePowerState()
+ of "turn-off":
+ let deviceId = parseInt(paramStr(2))
+
+ if devices[deviceId].name == "":
+ echo "This device doesn't exist."
+ quit(0)
+
+ discard devices[deviceId].setPowerState(false)
+
+ of "turn-on":
+ let deviceId = parseInt(paramStr(2))
+
+ if devices[deviceId].name == "":
+ echo "This device doesn't exist."
+ quit(0)
+
+ discard devices[deviceId].setPowerState(true)
+
of "setColor":
let deviceId = parseInt(paramStr(2))
@@ -69,4 +87,4 @@ if(paramCount() > 0):
echo pretty devicesJson
else:
- echo "tradfriCli\nUsage: ./trafriCli [params]\n\ndevices:\t\tLists devices. No additional options.\ntoggle:\t\t\tToggles device. Number from devices is needed as parameter\nsetColor:\t\tSets color for device. Number from devices is needed as parameter\ndevices-json:\t\tPrints out json of devices. No additional options\ndevices-json-pretty:\tSame as devices-json, but in pretty" \ No newline at end of file
+ echo "tradfriCli\nUsage: ./trafriCli [params]\n\ndevices:\t\tLists devices. No additional options.\ntoggle:\t\t\tToggles device. Number from devices is needed as parameter\nsetColor:\t\tSets color for device. Number from devices is needed as parameter\nturn-on:\t\tTurns the light on. Number from devices is needed as parameter\nturn-off:\t\tTurns the light off. Number from devices is needed as parameter\ndevices-json:\t\tPrints out json of devices. No additional options\ndevices-json-pretty:\tSame as devices-json, but in pretty" \ No newline at end of file