Class: Seam::Clients::ThermostatsDailyPrograms

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

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ ThermostatsDailyPrograms

Returns a new instance of ThermostatsDailyPrograms.



8
9
10
11
# File 'lib/seam/routes/thermostats_daily_programs.rb', line 8

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

Instance Method Details

#create(device_id:, name:, periods:) ⇒ Seam::Resources::ThermostatDailyProgram

Creates a new thermostat daily program. A daily program consists of a set of periods, where each period includes a start time and the key of a configured climate preset. Once you have defined a daily program, you can assign it to one or more days within a weekly program.

Parameters:

  • device_id

    ID of the thermostat device for which you want to create a daily program.

  • name

    Name of the thermostat daily program.

  • periods

    Array of thermostat daily program periods.

Returns:



18
19
20
21
22
# File 'lib/seam/routes/thermostats_daily_programs.rb', line 18

def create(device_id:, name:, periods:)
  res = @client.post("/thermostats/daily_programs/create", {device_id: device_id, name: name, periods: periods}.compact)

  Seam::Resources::ThermostatDailyProgram.load_from_response(res.body["thermostat_daily_program"])
end

#delete(thermostat_daily_program_id:) ⇒ nil

Deletes a thermostat daily program.

Parameters:

  • thermostat_daily_program_id

    ID of the thermostat daily program that you want to delete.

Returns:

  • (nil)

    OK



27
28
29
30
31
# File 'lib/seam/routes/thermostats_daily_programs.rb', line 27

def delete(thermostat_daily_program_id:)
  @client.post("/thermostats/daily_programs/delete", {thermostat_daily_program_id: thermostat_daily_program_id}.compact)

  nil
end

#update(name:, periods:, thermostat_daily_program_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt

Updates a specified thermostat daily program. The periods that you specify overwrite any existing periods for the daily program.

Parameters:

  • name

    Name of the thermostat daily program that you want to update.

  • periods

    Array of thermostat daily program periods. The periods that you specify overwrite any existing periods for the daily program.

  • thermostat_daily_program_id

    ID of the thermostat daily program that you want to update.

Returns:



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

def update(name:, periods:, thermostat_daily_program_id:, wait_for_action_attempt: nil)
  res = @client.post("/thermostats/daily_programs/update", {name: name, periods: periods, thermostat_daily_program_id: thermostat_daily_program_id}.compact)

  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt

  Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
end