1
0

HydrawiseZone.js 2.6 KB

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