1
0

Hydrawise.d.ts 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 Allow using a controller id instead of HydrawiseController object.
  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, controller?: HydrawiseController | number, duration?: number): Promise<any>;
  57. /**
  58. * Sends the run command to a single zone/relay
  59. * @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
  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: HydrawiseZone | number, 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(controller?: HydrawiseController, duration?: number): Promise<any>;
  70. /**
  71. * Sends the suspend command to a single zone/relay
  72. * @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
  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: HydrawiseZone | number, duration?: number): Promise<any>;
  77. /**
  78. * Sends the suspend command to all zones/relays for a specific controller
  79. * @param {number} [duration] - How long should the command be executed
  80. * @param {HydrawiseController|number} [controller] - Return zones for a specific controller. If not specified, the zones of the deault controller are returned.
  81. * @return {Promise} A Promise which will be resolved when the command has been executed.
  82. */
  83. suspendAllZones(controller?: HydrawiseController, duration?: number): Promise<any>;
  84. /**
  85. * Sends the stop command to a single zone/relay
  86. * @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
  87. * @return {Promise} A Promise which will be resolved when the command has been executed.
  88. */
  89. stopZone(zoneOrRelay: HydrawiseZone | number): Promise<any>;
  90. /**
  91. * Sends the stop command to all zones/relays
  92. * @return {Promise} A Promise which will be resolved when the command has been executed.
  93. */
  94. stopAllZones(controller?: HydrawiseController): Promise<any>;
  95. /**
  96. * Retrieves all zones/relays known to the server
  97. * @param {HydrawiseController|number} [controller] - Return zones for a specific controller. If not specified, the zones of the deault controller are returned.
  98. * @return {Promise} A Promise which will be resolved when all zones have been retrieved
  99. */
  100. getZones(controller?: HydrawiseController | number): Promise<HydrawiseZone[]>;
  101. /**
  102. * Retrieves all controllers known to the Hydrawise cloud or returns a single dummy one for a local connection
  103. * @return {Promise} A Promise which will be resolved when all controllers have been retrieved
  104. */
  105. getControllers(): Promise<HydrawiseController[]>;
  106. /**
  107. * Gets the customer ID & list of available controllers configured in the Hydrawise cloud. Only available in cloud binding.
  108. * @param {string} type - Defines the type of customer details to be retrieved alongside the customer ID
  109. * @return {Promise} A Promise which will be resolved when the request has returned from the cloud server.
  110. */
  111. getCustomerDetails(type: string): Promise<any>;
  112. /**
  113. * Gets the status and schedule of the locally connected controller or all controllers in the cloud
  114. * @param {number} [controller] - Return the status and schedule for a specific controller. If not specified, the zones of the deault controller are returned.
  115. * @return {Promise} A Promise which will be resolved when the request has returned from the local or cloud server.
  116. */
  117. getStatusAndSchedule(controller?: number): 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.relay_id] - The id of the relay which needs to be targetted. Not needed for runall, suspendall, stopall
  122. * @param {string} params.action - The action to be executed: run, stop, suspend, runall, suspendall, stopall
  123. * @param {number} [params.custom] - The amount of seconds the action needs to be run. Only for run, suspend, runall, suspendall
  124. * @param {number} [controller] - Needs to be specified if you have multiple controllers (cloud only)
  125. * @todo Complete params documentation
  126. * @return {Promise} A Promise which will be resolved when the request has returned from the local or cloud server.
  127. */
  128. setZone(params?: any, controller?: number): Promise<any>;
  129. }
  130. export {};
  131. //# sourceMappingURL=Hydrawise.d.ts.map