-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.py
More file actions
21 lines (15 loc) · 762 Bytes
/
set.py
File metadata and controls
21 lines (15 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import argparse
import os
import socket
parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument("device_address", help="The address of the device you want to execute the action for.")
parser.add_argument("action", help="The action to execute for the device", choices=['power', 'brightness', 'color', 'temperature'])
parser.add_argument("action_args", help="The action arguments", nargs='*')
args = parser.parse_args()
app_path = os.path.dirname(os.path.realpath(__file__))
sock_path = app_path + '/var/huey.sock'
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect(sock_path)
action_args_str = '|'.join(args.action_args)
message = f"{args.device_address}|{args.action}|{action_args_str}"
client.send(message.encode())