Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/alice-smart-home.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-05-23 18:08:34 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-05-23 18:08:34 +0300
commit675d5eb06743b4a825609903adb4c657f9c51e0d (patch)
tree21aab68de7c7a1f44d73b8f2b492f82ad669aa0b /devices
initial commit
Diffstat (limited to 'devices')
-rw-r--r--devices/pc.json18
-rw-r--r--devices/pc.py15
2 files changed, 33 insertions, 0 deletions
diff --git a/devices/pc.json b/devices/pc.json
new file mode 100644
index 0000000..f09b6d9
--- /dev/null
+++ b/devices/pc.json
@@ -0,0 +1,18 @@
+{
+ "name": "Компьютер",
+ "description": "Основной компьютер",
+ "room": "Моя комната",
+ "type": "devices.types.switch",
+ "capabilities": [
+ {
+ "type": "devices.capabilities.on_off",
+ "retrievable": true
+ }
+ ],
+ "device_info": {
+ "manufacturer": "Cluster",
+ "model": "0",
+ "hw_version": "1.0",
+ "sw_version": "1.0"
+ }
+}
diff --git a/devices/pc.py b/devices/pc.py
new file mode 100644
index 0000000..00b2504
--- /dev/null
+++ b/devices/pc.py
@@ -0,0 +1,15 @@
+import subprocess
+
+def pc_query(capability_type, instance):
+ if capability_type == "devices.capabilities.on_off":
+ p = subprocess.run(["ping", "-c", "1", "192.168.0.2"], stdout=subprocess.PIPE)
+ state = p.returncode == 0
+ return state
+
+def pc_action(capability_type, instance, value, relative):
+ if capability_type == "devices.capabilities.on_off":
+ if value:
+ subprocess.run(["wakeonlan", "-i", "192.168.0.255", "00:11:22:33:44:55"])
+ else:
+ subprocess.run(["sh", "-c", "echo shutdown -h | ssh clust@192.168.0.2"])
+ return "DONE"