This adapter is used by WEB applications and adapters to communicate with ioBroker using websockets.
It is almost the same as ioBroker.socketio
, but does not use socket.io library and only simulates it.
Important Note: Since v4.0 of this adapter pure Websockets are used exclusively! Socket.io is no longer implemented by the socket.io library, but simulated via pure WebSockets!
Users can use this adapter to connect their products to ioBroker via web sockets. Actually, this adapter could be used by echarts, vis and many other adapters to extract data from ioBroker.
You can find in the example directory simple application that uses this interface to show some data.
By using of socket.io interface user should understand the basics and concept of the system.
It is useful to read about the structure of the objects too.
This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers. For more details and for information how to disable the error reporting see Sentry-Plugin Documentation! Sentry reporting is used starting with js-controller 3.0.
Object is description of data point or group. The group could content other data points in this case it called channel. If a group consists of other channels, in this case it is called device.
Object is meta information that describes data point and could content: max/min value, unit, name, default value, type of value, information for adapter for communication (e.g., ip address) and so on.
State is the actual value of the data point and presented by javascript object:
{
val: VALUE,
ack: ACKNOWLEDGED,
ts: TIMESTAMP, // could be converted into time with "new Date(state.ts)" (In older version of js-controller - "new Date(state.ts * 1000)")
lc: TIMESTAMP of last change,
from: ADAPTER_NAME,
q: QUALITY
}
States change itself very frequently in compare to the objects. (Normally objects should be changed once by creation and that's all)
Every state has the attribute ack
. It shows the direction of command.
- If ack=false, it means some other adapter wants to control (write) this variable, so that command will be executed (e.g., light will be switched on).
- If ack=true, it means that the device informs about new value. (e.g., light was switched on manually or motion was detected)
Example: we have some home automation adapter (HAA) that has one lamp connected under address haa.0.lamp1
.
- Lamp can be switched on manually with physical switch or via Wi-Fi with the help of HAA.
- If vis wants to switch the lamp on via Wi-Fi, it should set the new value with
{value: true, ack: false}
. - When the lamp is switched on it is normally informing HAA about new state and the value should be immediately overwritten with
{value: true, ack: true}
. - If the lamp is switched off manually via physical switch it informs HAA about new state with
{value: false, ack: true}
.
Every data point has an attribute q
- quality.
You can find the description of every supported method here.
It is suggested to use socket class for communication.
- (bluefox) Corrected call of getObjectView with null parameter
- (foxriver76) fixed require of webserver
- (foxriver76) use
@iobroker/webserver
- (bluefox) Some packages were updated
- (foxriver76) updated ws-server to increase the file limit to 500 MB
- (joltcoke) Corrected the crash if authentication is enabled
- (bluefox) Corrected adapter termination if the alias has no target
- (foxriver76) upgraded socket-classes to fix vis problems
- (bluefox) upgraded socket-classes to correct the error by unsubscribing on client disconnect
- (foxriver76) upgraded socket-classes to fix crash cases
- (mcm1957) added missing node16 requirement
- (bluefox) Added the subscribing on the specific instance messages
- (bluefox) extended the getObjects function with the possibility to read the list of IDs
- (bluefox) Allowed deletion of fullcalendar objects
- (bluefox) added
publishFileAll
method (for future use)
- (bluefox) corrected connection string
- (bluefox) used new socket-classes
- (bluefox) Added
fileChange
event
The MIT License (MIT)
Copyright (c) 2014-2024 bluefox dogafox@gmail.com