lib/arlo/devices.rb in arlo-0.0.5 vs lib/arlo/devices.rb in arlo-0.0.6
- old
+ new
@@ -56,11 +56,11 @@
payload = {
'cameraId': camera_id,
'parentId': camera_id,
'deviceId': camera_id,
- 'olsonTimeZone': 'Americal/New York'
+ 'olsonTimeZone': camera['properties']['olsonTimeZone']
}
ret_val = post('https://arlo.netgear.com/hmsweb/users/devices/takeSnapshot',
payload, 'xcloudId': camera['xCloudId'])
@@ -82,8 +82,59 @@
ret_val = post('https://arlo.netgear.com/hmsweb/users/devices/stopStream',
payload, 'xcloudId': camera['xCloudId'])
JSON.parse(ret_val.body)
snapshot_ret_val
+ end
+
+ def record_video(camera, duration)
+ camera_id = camera['deviceId']
+ parent_id = camera['parentId']
+
+ payload = {
+ 'to': parent_id,
+ 'from': 'ArloGem',
+ 'resource': "cameras/#{camera_id}",
+ 'action': 'set',
+ 'responseUrl': '',
+ 'publishResponse': true,
+ 'transId': SecureRandom.uuid,
+ 'properties': {
+ 'activityState': 'startUserStream',
+ 'cameraId': camera_id
+ }
+ }
+
+ ret_val = post('https://arlo.netgear.com/hmsweb/users/devices/startStream',
+ payload, 'xcloudId': camera['xCloudId'])
+
+ ret_val = JSON.parse(ret_val.body)
+ payload = {
+ 'xcloudId': camera['xCloudId'],
+ 'parentId': camera['parentId'],
+ 'deviceId': camera_id,
+ 'olsonTimeZone': camera['properties']['olsonTimeZone']
+
+ }
+
+ ret_val = post('https://arlo.netgear.com/hmsweb/users/devices/startRecord',
+ payload, 'xcloudId': camera['xCloudId'])
+
+ JSON.parse(ret_val.body)
+
+ sleep(duration)
+
+ payload = {
+ 'xcloudId': camera['xCloudId'],
+ 'parentId': camera['parentId'],
+ 'deviceId': camera_id,
+ 'olsonTimeZone': camera['properties']['olsonTimeZone']
+
+ }
+
+ ret_val = post('https://arlo.netgear.com/hmsweb/users/devices/stopRecord',
+ payload, 'xcloudId': camera['xCloudId'])
+
+ JSON.parse(ret_val.body)
end
end
end