Class: Seam::Clients::NoiseSensorsNoiseThresholds

Inherits:
Object
  • Object
show all
Defined in:
lib/seam/routes/noise_sensors_noise_thresholds.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ NoiseSensorsNoiseThresholds

Returns a new instance of NoiseSensorsNoiseThresholds.



6
7
8
9
# File 'lib/seam/routes/noise_sensors_noise_thresholds.rb', line 6

def initialize(client:, defaults:)
  @client = client
  @defaults = defaults
end

Instance Method Details

#create(device_id:, ends_daily_at:, starts_daily_at:, name: nil, noise_threshold_decibels: nil, noise_threshold_nrs: nil) ⇒ Seam::Resources::NoiseThreshold

Creates a new noise threshold for a noise sensor. Thresholds represent the limits of noise tolerated at a property, which can be customized for each hour of the day. Each device has its own default thresholds, but you can use the Seam API to modify them.

Parameters:

  • device_id

    ID of the device for which you want to create a noise threshold.

  • ends_daily_at

    Time at which the new noise threshold should become inactive daily.

  • starts_daily_at

    Time at which the new noise threshold should become active daily.

  • name (defaults to: nil)

    Name of the new noise threshold.

  • noise_threshold_decibels (defaults to: nil)

    Noise level in decibels for the new noise threshold.

  • noise_threshold_nrs (defaults to: nil)

    Noise level in Noiseaware Noise Risk Score (NRS) for the new noise threshold. This parameter is only relevant for Noiseaware sensors.

Returns:



19
20
21
22
23
# File 'lib/seam/routes/noise_sensors_noise_thresholds.rb', line 19

def create(device_id:, ends_daily_at:, starts_daily_at:, name: nil, noise_threshold_decibels: nil, noise_threshold_nrs: nil)
  res = @client.post("/noise_sensors/noise_thresholds/create", {device_id: device_id, ends_daily_at: ends_daily_at, starts_daily_at: starts_daily_at, name: name, noise_threshold_decibels: noise_threshold_decibels, noise_threshold_nrs: noise_threshold_nrs}.compact)

  Seam::Resources::NoiseThreshold.load_from_response(res.body["noise_threshold"])
end

#delete(device_id:, noise_threshold_id:) ⇒ nil

Deletes a noise threshold from a noise sensor.

Parameters:

  • device_id

    ID of the device that contains the noise threshold that you want to delete.

  • noise_threshold_id

    ID of the noise threshold that you want to delete.

Returns:

  • (nil)

    OK



29
30
31
32
33
# File 'lib/seam/routes/noise_sensors_noise_thresholds.rb', line 29

def delete(device_id:, noise_threshold_id:)
  @client.post("/noise_sensors/noise_thresholds/delete", {device_id: device_id, noise_threshold_id: noise_threshold_id}.compact)

  nil
end

#get(noise_threshold_id:) ⇒ Seam::Resources::NoiseThreshold

Returns a specified noise threshold for a noise sensor.

Parameters:

  • noise_threshold_id

    ID of the noise threshold that you want to get.

Returns:



38
39
40
41
42
# File 'lib/seam/routes/noise_sensors_noise_thresholds.rb', line 38

def get(noise_threshold_id:)
  res = @client.post("/noise_sensors/noise_thresholds/get", {noise_threshold_id: noise_threshold_id}.compact)

  Seam::Resources::NoiseThreshold.load_from_response(res.body["noise_threshold"])
end

#list(device_id:) ⇒ Seam::Resources::NoiseThreshold

Returns a list of all noise thresholds for a noise sensor.

Parameters:

  • device_id

    ID of the device for which you want to list noise thresholds.

Returns:



47
48
49
50
51
# File 'lib/seam/routes/noise_sensors_noise_thresholds.rb', line 47

def list(device_id:)
  res = @client.post("/noise_sensors/noise_thresholds/list", {device_id: device_id}.compact)

  Seam::Resources::NoiseThreshold.load_from_response(res.body["noise_thresholds"])
end

#update(device_id:, noise_threshold_id:, ends_daily_at: nil, name: nil, noise_threshold_decibels: nil, noise_threshold_nrs: nil, starts_daily_at: nil) ⇒ nil

Updates a noise threshold for a noise sensor.

Parameters:

  • device_id

    ID of the device that contains the noise threshold that you want to update.

  • noise_threshold_id

    ID of the noise threshold that you want to update.

  • ends_daily_at (defaults to: nil)

    Time at which the noise threshold should become inactive daily.

  • name (defaults to: nil)

    Name of the noise threshold that you want to update.

  • noise_threshold_decibels (defaults to: nil)

    Noise level in decibels for the noise threshold.

  • noise_threshold_nrs (defaults to: nil)

    Noise level in Noiseaware Noise Risk Score (NRS) for the noise threshold. This parameter is only relevant for Noiseaware sensors.

  • starts_daily_at (defaults to: nil)

    Time at which the noise threshold should become active daily.

Returns:

  • (nil)

    OK



62
63
64
65
66
# File 'lib/seam/routes/noise_sensors_noise_thresholds.rb', line 62

def update(device_id:, noise_threshold_id:, ends_daily_at: nil, name: nil, noise_threshold_decibels: nil, noise_threshold_nrs: nil, starts_daily_at: nil)
  @client.post("/noise_sensors/noise_thresholds/update", {device_id: device_id, noise_threshold_id: noise_threshold_id, ends_daily_at: ends_daily_at, name: name, noise_threshold_decibels: noise_threshold_decibels, noise_threshold_nrs: noise_threshold_nrs, starts_daily_at: starts_daily_at}.compact)

  nil
end