1
0

Hydrawise.d.ts 9.0 KB

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