1
0

HydrawiseZone.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. /**
  3. * @author Martijn Dierckx
  4. */
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. /** Class representing a Hydrawise zone */
  7. class HydrawiseZone {
  8. /**
  9. * Create a new instance of a HydrawiseZone
  10. * @param {object} options - Options object containing all parameters
  11. * @param {Hydrawise} options.apiBinding - The API binding which can be used to execute commands on the zone
  12. * @param {number} options.relayID - The unique relay number known to the Hydrawise cloud
  13. * @param {number} options.zone - The local zone/relay number
  14. * @param {string} options.name - The name of the zone
  15. * @param {Date} options.nextRunAt - The date & time of the next scheduled run
  16. * @param {number} options.nextRunDuration - Run time in seconds of the next run defined by nextRunAt
  17. * @param {boolean} options.isSuspended - Returns true when the zoneis currently suspended
  18. * @param {boolean} options.isRunning - Returns true when the zone is actively running
  19. * @param {number} options.remainingRunningTime - Remaining run time in seconds when isRunning = true
  20. */
  21. constructor(options) {
  22. this.apiBinding = options.apiBinding;
  23. this.relayID = options.relayID;
  24. this.zone = options.zone;
  25. this.name = options.name;
  26. this.nextRunAt = options.nextRunAt;
  27. this.nextRunDuration = options.nextRunDuration;
  28. this.isSuspended = options.isSuspended;
  29. this.isRunning = options.isRunning;
  30. this.remainingRunningTime = options.remainingRunningTime;
  31. }
  32. /**
  33. * Sends the run command to the zone/relay
  34. * @param {number} [duration] - How long should the command be executed
  35. * @return {Promise} A Promise which will be resolved when the command has been executed.
  36. */
  37. run(duration) {
  38. return this.apiBinding.commandZone('run', this, duration);
  39. }
  40. /**
  41. * Sends the stop command to the zone/relay
  42. * @return {Promise} A Promise which will be resolved when the command has been executed.
  43. */
  44. stop() {
  45. return this.apiBinding.commandZone('stop', this);
  46. }
  47. /**
  48. * Sends the suspend command to the zone/relay
  49. * @param {number} [duration] - How long should the command be executed
  50. * @return {Promise} A Promise which will be resolved when the command has been executed.
  51. */
  52. suspend(duration) {
  53. return this.apiBinding.commandZone('suspend', this, duration);
  54. }
  55. }
  56. exports.HydrawiseZone = HydrawiseZone;
  57. //# sourceMappingURL=HydrawiseZone.js.map