-
Notifications
You must be signed in to change notification settings - Fork 163
/
sendtovera.py
executable file
·89 lines (80 loc) · 2.13 KB
/
sendtovera.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/local/bin/python3.7m
import os
import re
import requests
import time
import sys
veraip = "192.168.1.39"
port = 3480
temperaturedeviceid = 769
humiditydeviceid = 772
# Quick and dirty script to send data to vera sensors
# sensorname=$2 temperature=$3,humidity=$4,calibratedHumidity=$5,batterylevel=$6 $7
temperature = sys.argv[3] # change to sys.argv[5] for calibrated
humidity = sys.argv[4]
batterylevel = sys.argv[6]
# send temperature value
res = requests.get(
"http://"
+ veraip
+ ":"
+ str(port)
+ "/data_request?id=variableset&DeviceNum="
+ str(temperaturedeviceid)
+ "&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="
+ str(temperature)
)
# send timestamp
res = requests.get(
"http://"
+ veraip
+ ":"
+ str(port)
+ "/data_request?id=variableset&DeviceNum="
+ str(temperaturedeviceid)
+ "&serviceId=urn:micasaverde-com:serviceId:HaDevice1&Variable=LastUpdate&Value="
+ str(int(time.time()))
)
# send humidity value
res = requests.get(
"http://"
+ veraip
+ ":"
+ str(port)
+ "/data_request?id=variableset&DeviceNum="
+ str(humiditydeviceid)
+ "&serviceId=urn:micasaverde-com:serviceId:HumiditySensor1&Variable=CurrentLevel&Value="
+ str(humidity)
)
# change update timestamp
res = requests.get(
"http://"
+ veraip
+ ":"
+ str(port)
+ "/data_request?id=variableset&DeviceNum="
+ str(humiditydeviceid)
+ "&serviceId=urn:micasaverde-com:serviceId:HaDevice1&Variable=LastUpdate&Value="
+ str(int(time.time()))
)
# send batterylevel to temp and humidity virtual sensors
res = requests.get(
"http://"
+ veraip
+ ":"
+ str(port)
+ "/data_request?id=variableset&DeviceNum="
+ str(temperaturedeviceid)
+ "&serviceId=urn:micasaverde-com:serviceId:HaDevice1&Variable=BatteryLevel&Value="
+ str(batterylevel)
)
res = requests.get(
"http://"
+ veraip
+ ":"
+ str(port)
+ "/data_request?id=variableset&DeviceNum="
+ str(humiditydeviceid)
+ "&serviceId=urn:micasaverde-com:serviceId:HaDevice1&Variable=BatteryLevel&Value="
+ str(batterylevel)
)