HydrawiseController.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. /**
  3. * @author Martijn Dierckx
  4. */
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.HydrawiseController = void 0;
  7. /** Class representing a Hydrawise controller */
  8. class HydrawiseController {
  9. /**
  10. * Create a new instance of a HydrawiseController
  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.id - The unique identifier of the controller
  14. * @param {string} options.name - The name of the controller
  15. * @param {string} options.serialNumber - The serial number of the controller
  16. * @param {Date} options.lastContactWithCloud - The last date time the controller was able to contact/sync with the cloud
  17. * @param {string} options.status - The status as returned by the Hydrawise cloud
  18. */
  19. constructor(options) {
  20. this.apiBinding = options.apiBinding;
  21. this.id = options.id;
  22. this.name = options.name;
  23. this.serialNumber = options.serialNumber;
  24. this.lastContactWithCloud = options.lastContactWithCloud;
  25. this.status = options.status;
  26. }
  27. /**
  28. * Retrieves all zones/relays known to the server for this controller
  29. * @return {Promise} A Promise which will be resolved when all zones have been retrieved
  30. */
  31. getZones() {
  32. return this.apiBinding.getZones(this);
  33. }
  34. /**
  35. * Sends the run command to all the zones/relays of the controller
  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. runAllZones(duration) {
  40. return this.apiBinding.commandAllZones('runall', this, duration);
  41. }
  42. /**
  43. * Sends the stop command to all the zones/relays of the controller
  44. * @return {Promise} A Promise which will be resolved when the command has been executed.
  45. */
  46. stopAllZones() {
  47. return this.apiBinding.commandAllZones('stopall', this);
  48. }
  49. /**
  50. * Sends the suspend command to all the zones/relays of the controller
  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. suspendAllZones(duration) {
  55. return this.apiBinding.commandAllZones('suspendall', this, duration);
  56. }
  57. }
  58. exports.HydrawiseController = HydrawiseController;
  59. //# sourceMappingURL=HydrawiseController.js.map