1
0

HydrawiseZone.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. * @param {HydrawiseController} [options.controller] - The controller linked to the zone
  21. */
  22. constructor(options) {
  23. this.apiBinding = options.apiBinding;
  24. this.relayID = options.relayID;
  25. this.zone = options.zone;
  26. this.name = options.name;
  27. this.nextRunAt = options.nextRunAt;
  28. this.nextRunDuration = options.nextRunDuration;
  29. this.isSuspended = options.isSuspended;
  30. this.isRunning = options.isRunning;
  31. this.remainingRunningTime = options.remainingRunningTime;
  32. this.controller = options.controller;
  33. }
  34. /**
  35. * Sends the run command to the zone/relay
  36. * @param {number} [duration] - How long should the command be executed
  37. * @return {Promise} A Promise which will be resolved when the command has been executed.
  38. */
  39. run(duration) {
  40. return this.apiBinding.commandZone('run', this, duration);
  41. }
  42. /**
  43. * Sends the stop command to the zone/relay
  44. * @return {Promise} A Promise which will be resolved when the command has been executed.
  45. */
  46. stop() {
  47. return this.apiBinding.commandZone('stop', this);
  48. }
  49. /**
  50. * Sends the suspend command to the zone/relay
  51. * @param {number} [duration] - How long should the command be executed
  52. * @return {Promise} A Promise which will be resolved when the command has been executed.
  53. */
  54. suspend(duration) {
  55. return this.apiBinding.commandZone('suspend', this, duration);
  56. }
  57. }
  58. exports.HydrawiseZone = HydrawiseZone;
  59. //# sourceMappingURL=HydrawiseZone.js.map