Sha256: a76996538c9f5eece34bfc14e3434f13e5a75f4f0fe5b8f353027ddb1b188a50

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

require 'securerandom'

module Arlo
  class API
    def get_devices
      devices = get 'https://arlo.netgear.com/hmsweb/users/devices'
      @devices = JSON.parse(devices.body)
    end

    def get_device_info(device_name)
      raise 'Missing device_name' unless device_name
      @devices['data'].select {|device| device['deviceName'] == device_name }[0]
    end

    def arm_device(base_station, armed)
      station_id = base_station['deviceId']
      payload = {
        'from': 'arlogem',
        'to': station_id,
        'action': 'set',
        'resource': 'modes',
        'transId': SecureRandom.uuid,
        'publishResponse': true,
        'properties': {
          'active': armed ? 'mode1' : 'mode0'
        }
      }

      ret_val = post("https://arlo.netgear.com/hmsweb/users/devices/notify/#{station_id}",
                     payload,
                     'xcloudId': base_station['xCloudId'])
      JSON.parse(ret_val.body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arlo-0.0.4 lib/arlo/devices.rb