HydrawiseController.js 2.5 KB

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