Class: Seam::Clients::ThermostatsDailyPrograms
- Inherits:
-
Object
- Object
- Seam::Clients::ThermostatsDailyPrograms
- Defined in:
- lib/seam/routes/thermostats_daily_programs.rb
Instance Method Summary collapse
-
#create(device_id:, name:, periods:) ⇒ Seam::Resources::ThermostatDailyProgram
Creates a new thermostat daily program.
-
#delete(thermostat_daily_program_id:) ⇒ nil
Deletes a thermostat daily program.
-
#initialize(client:, defaults:) ⇒ ThermostatsDailyPrograms
constructor
A new instance of ThermostatsDailyPrograms.
-
#update(name:, periods:, thermostat_daily_program_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Updates a specified thermostat daily program.
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.
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.
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.
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 |