Difference between revisions of "EventStream Interface"
(→connect) |
|||
Line 16: | Line 16: | ||
:::''pingInterval'' - The number of seconds to send a ping message. Defaults to 0 (disabled). | :::''pingInterval'' - The number of seconds to send a ping message. Defaults to 0 (disabled). | ||
:::''headers'' - A Map of key/value pairs to send as header values when connecting to the web socket server. | :::''headers'' - A Map of key/value pairs to send as header values when connecting to the web socket server. | ||
+ | :::''ignoreSSLIssues'' (since 2.2.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false. | ||
+ | :::''rawData'' (since 2.2.2) - possible values: true, false. Prevents parsing of the data read from the stream and returns the raw data to the caller. Defaults to false. | ||
+ | :::''readTimeout'' (since 2.2.9) - The number of seconds before a read times out. Defaults to 60. | ||
+ | |||
===<code>close</code>=== | ===<code>close</code>=== | ||
Line 26: | Line 30: | ||
// Close connection | // Close connection | ||
interfaces.eventStream.close() | interfaces.eventStream.close() | ||
− | |||
==User defined methods== | ==User defined methods== |
Revision as of 02:11, 15 November 2021
Contents
Overview
Hubitat allows for opening and maintaining a connection to an event stream endpoint from the hub. All code needs to be contained in a driver, there is no option to open an event stream connection from an app. Hubitat provides methods to connect and disconnect to the endpoint, in addition it is required to create a method in the driver that accepts incoming messages (parse) and another method that will be called with any status updates for the endpoint (eventStreamStatus).
Methods
Hubitat Provided Methods
connect
- Signature
void connect(String url)
void connect(String url, [options (name/value pairs)])
- Parameters
- url - The url to connect to.
- options - Optional parameters to configure the web socket connection. Possible values:
- pingInterval - The number of seconds to send a ping message. Defaults to 0 (disabled).
- headers - A Map of key/value pairs to send as header values when connecting to the web socket server.
- ignoreSSLIssues (since 2.2.8) - possible values: true, false. Ignores certificate issues for SSL connections. Cert does not have to be from a trusted authority and the hostname does not need to be verified. This is primarily for dev situations that make use of localhost, build, and test servers. Defaults to false.
- rawData (since 2.2.2) - possible values: true, false. Prevents parsing of the data read from the stream and returns the raw data to the caller. Defaults to false.
- readTimeout (since 2.2.9) - The number of seconds before a read times out. Defaults to 60.
close
- Signature
void close()
- Examples
// Close connection interfaces.eventStream.close()
User defined methods
parse(String message)
- This method is called with any incoming messages from the event stream server. This is a standard method for drivers.
eventStreamStatus(String message)
- This method is called with any status messages from the event stream client connection (disconnections, errors during connect, etc)