Hydrawise.d.ts 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * @author Miroslav Abrahám - Further modifications and fixes
  3. * @author Martijn Dierckx - Complete rewrite to service both the cloud & local API binding
  4. * @author Paul Molluzzo (https://paulmolluzzo.com) - Initial 0.1.0 version containing the cloud binding
  5. */
  6. import { HydrawiseConnectionType } from './HydrawiseConnectionType';
  7. import { HydrawiseZone } from './HydrawiseZone';
  8. import { HydrawiseController } from './HydrawiseController';
  9. interface HydrawiseConfiguration {
  10. type: HydrawiseConnectionType;
  11. host?: string;
  12. user?: string;
  13. password?: string;
  14. key?: string;
  15. }
  16. /** Class representing a Hydrawise local or cloud based API binding */
  17. export declare class Hydrawise {
  18. private readonly cloudUrl;
  19. type: HydrawiseConnectionType;
  20. url: string;
  21. localAuthUsername: string;
  22. localAuthPassword: string;
  23. cloudAuthAPIkey: string;
  24. /**
  25. * Create a new instance of the Hydrawise API binding
  26. * @param {object} options - Options object containing all parameters
  27. * @param {string} options.type - The type of binding you wish to make: 'CLOUD' or 'LOCAL'
  28. * @param {string} [options.host] - The hostname or ip address of the local host you wish to connect to. Only needed for local bindings.
  29. * @param {string} [options.user = admin] - The username of the local Hydrawise controller. Only needed for local bindings (falls back to the default 'admin' user).
  30. * @param {string} [options.password] - The password of the local Hydrawise controller. Only needed for local bindings.
  31. * @param {string} [options.key] - The API key of your Hydrawise cloud account. Only needed for cloud bindings.
  32. */
  33. constructor(options: HydrawiseConfiguration);
  34. /**
  35. * Private function that makes a GET request to the local or cloud Hydrawise server
  36. * @param {string} path - The path of the API endpoint
  37. * @param {object} [params] - Parameters to be added to the URL path
  38. * @return {Promise} A Promise which will be resolved when the request has returned from the local or cloud server.
  39. */
  40. private request;
  41. /**
  42. * Sends a command to a single zone/relay
  43. * @param {string} action - The required command to be executed for the given zone/relay: run, suspend, stop
  44. * @param {(HydrawiseZone|number|number)} zoneOrRelay - The zone/relay you are targetting. Can be a zone object returned by getZones, a relay number (zone.zone) for local bindings or a relayID (zone.relayID) for cloud bindings
  45. * @param {number} [duration] - How long should the command be executed (only applicable for run & suspend)
  46. * @todo Allow using a controller id instead of HydrawiseController object.
  47. * @return {Promise} A Promise which will be resolved when the command has been executed.
  48. */
  49. commandZone(action: string, zoneOrRelay: number | HydrawiseZone, duration?: number): Promise<any>;
  50. /**
  51. * Sends a command to all zones/relays
  52. * @param {string} action - The required command to be executed: runall, suspendall, stopall
  53. * @param {number} [duration] - How long should the given command be executed (only applicable for runall & suspendall)
  54. * @todo Check whether controller_id needs to sent when the account contains multiple zones
  55. * @return {Promise} A Promise which will be resolved when the command has been executed.
  56. */
  57. commandAllZones(action: string, controller?: HydrawiseController | number, duration?: number): Promise<any>;
  58. /**
  59. * Sends the run command to a single zone/relay
  60. * @param {(HydrawiseZone|number)} zoneOrRelay - The zone/relay you are targetting. Can be a zone object returned by getZones, a relay number (zone.zone) for local bindings or a relayID (zone.relayID) for cloud bindings
  61. * @param {number} [duration] - How long should the command be executed
  62. * @return {Promise} A Promise which will be resolved when the command has been executed.
  63. */
  64. runZone(zoneOrRelay: HydrawiseZone | number, duration?: number): Promise<any>;
  65. /**
  66. * Sends the run command to all zones/relays
  67. * @param {number} [duration] - How long should the command be executed
  68. * @return {Promise} A Promise which will be resolved when the command has been executed.
  69. */
  70. runAllZones(controller?: HydrawiseController, duration?: number): Promise<any>;
  71. /**
  72. * Sends the suspend command to a single zone/relay
  73. * @param {(HydrawiseZone|number)} zoneOrRelay - The zone/relay you are targetting. Can be a zone object returned by getZones, a relay number (zone.zone) for local bindings or a relayID (zone.relayID) for cloud bindings
  74. * @param {number} [duration] - How long should the command be executed
  75. * @return {Promise} A Promise which will be resolved when the command has been executed.
  76. */
  77. suspendZone(zoneOrRelay: HydrawiseZone | number, duration?: number): Promise<any>;
  78. /**
  79. * Sends the suspend command to all zones/relays for a specific controller
  80. * @param {number} [duration] - How long should the command be executed
  81. * @param {HydrawiseController|number} [controller] - Return zones for a specific controller. If not specified, the zones of the deault controller are returned.
  82. * @return {Promise} A Promise which will be resolved when the command has been executed.
  83. */
  84. suspendAllZones(controller?: HydrawiseController, duration?: number): Promise<any>;
  85. /**
  86. * Sends the stop command to a single zone/relay
  87. * @param {(HydrawiseZone|number)} zoneOrRelay - The zone/relay you are targetting. Can be a zone object returned by getZones, a relay number (zone.zone) for local bindings or a relayID (zone.relayID) for cloud bindings
  88. * @return {Promise} A Promise which will be resolved when the command has been executed.
  89. */
  90. stopZone(zoneOrRelay: HydrawiseZone | number): Promise<any>;
  91. /**
  92. * Sends the stop command to all zones/relays
  93. * @return {Promise} A Promise which will be resolved when the command has been executed.
  94. */
  95. stopAllZones(controller?: HydrawiseController): Promise<any>;
  96. /**
  97. * Retrieves all zones/relays known to the server
  98. * @param {HydrawiseController|number} [controller] - Return zones for a specific controller. If not specified, the zones of the deault controller are returned.
  99. * @return {Promise} A Promise which will be resolved when all zones have been retrieved
  100. */
  101. getZones(controller?: HydrawiseController | number): Promise<HydrawiseZone[]>;
  102. /**
  103. * Retrieves all controllers known to the Hydrawise cloud or returns a single dummy one for a local connection
  104. * @return {Promise} A Promise which will be resolved when all controllers have been retrieved
  105. */
  106. getControllers(): Promise<HydrawiseController[]>;
  107. /**
  108. * Gets the customer ID & list of available controllers configured in the Hydrawise cloud. Only available in cloud binding.
  109. * @param {string} type - Defines the type of customer details to be retrieved alongside the customer ID
  110. * @return {Promise} A Promise which will be resolved when the request has returned from the cloud server.
  111. */
  112. getCustomerDetails(type: string): Promise<any>;
  113. /**
  114. * Gets the status and schedule of the locally connected controller or all controllers in the cloud
  115. * @param {number} [controller] - Return the status and schedule for a specific controller. If not specified, the zones of the deault controller are returned.
  116. * @return {Promise} A Promise which will be resolved when the request has returned from the local or cloud server.
  117. */
  118. getStatusAndSchedule(controller?: number): Promise<any>;
  119. /**
  120. * Sends an action request to a specific or all zones
  121. * @param {object} params - Parameters object containing all parameters to be sent along with the request
  122. * @param {string} [params.relay_id] - The id of the relay which needs to be targetted. Not needed for runall, suspendall, stopall
  123. * @param {string} params.action - The action to be executed: run, stop, suspend, runall, suspendall, stopall
  124. * @param {number} [params.custom] - The amount of seconds the action needs to be run. Only for run, suspend, runall, suspendall
  125. * @param {number} [controller] - Needs to be specified if you have multiple controllers (cloud only)
  126. * @todo Complete params documentation
  127. * @return {Promise} A Promise which will be resolved when the request has returned from the local or cloud server.
  128. */
  129. setZone(params?: any, controller?: number): Promise<any>;
  130. }
  131. export {};
  132. //# sourceMappingURL=Hydrawise.d.ts.map