Communication - SerialProxy

.

Plugin details

Type: Communication

Port Type: Serial

Name: SerialProxy

Status: COLLECTION C

GitHub: P087_SerialProxy.ino

Maintainer: TD-er

Used libraries: ESPEasySerial

Configuration

../_images/P087_DeviceConfiguration.png
  • Name A unique name should be entered here.

  • Enabled The device can be disabled or enabled. When not enabled the device should not use any resources.

Sensor

See: Serial Helper configuration

Filtering

This section only shows settings when the plugin is configured and enabled.

../_images/P087_FilteringConfiguration.png
  • RegEx: Specify a regular expression to apply to the received data before it is accepted as acceptable data. This regular expression is based on the Lua script language, and is documented here: http://www.lua.org/manual/5.2/manual.html#6.4.1

  • Nr Chars use in RegEx: Limit the length of the data to be checked using the RegEx regular expression filter. When set to 0 all data is checked.

  • Filter Off Window after send: The time in milliseconds to turn off filtering after receiving data that is accepted by the filter. Setting this to 0 will not turn off the filter after sending to the connected device.

  • Match Type: Select the type of matching that is to be applied:

../_images/P087_MatchTypeOptions.png
  • Regular Match: Use the Regular Expression matching, configured above.

  • Regular Match inverted: Use the Regular Expression matching but with inverting the result, as configured above.

  • Global Match: Use the group values defined the Regular Expression above, to compare to the Capture Filter 1..10 definitions explained below.

  • Global Match inverted: Like Global Match, inverting the outcome.

  • Filter Disabled: No filtering is applied.

Capture Filter 1..10

Each Capture Filter has 3 fields:

  • Group: Refer to the group index as returned from the Regular Expression, range 1..32.

  • Comparison: The comparison can be Equals or Not Equals:

../_images/P087_ComparisonOptions.png
  • Compared value: The literal value that should match the value from the RegEx Group chosen, and compared using the Comparison.

Statistics

Statistic data is only visible if the plugin is configured and enabled.

../_images/P087_StatisticsConfiguration.png

This shows the latest data received and some statistics.

Data Acquisition

This group of settings, Single event with all values and Send to Controller settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured.

  • Interval By default, Interval will be set to 60 sec.

Values

The Values are not changed during processing, and can be ignored.

Commands available

Command

Extra information

serialproxy_write,'<content>'

Content: Data to send out via the serial port. Should use quotes when containing spaces or commas.

Send out data via the configured serial port.

serialproxy_writemix,'<content to send>'[,...]

<content to send>: Text and/or hex byte(s) (having 0x prefix) that will be sent (nearly) unprocessed. Only the regular variable replacements will be applied before sending the content to the serial port.

This command requires quotes to be used if spaces or commas are part of the content.

Any data can be sent, even if it can not be typed in a text content, by specifying that as a separate argument: serialproxy_writemix,'text, optionally including spaces or commas',0xXX,'0xXXxx XX,xx-XX:xx'

'text, optionally including spaces or commas': Any text content to be sent to the serial port. Can contain variables. Quotes are only required if spaces or commas (separators) are used.

0xXX: A single character in hexadecimal notation (range: 0x00..0xFF), that is appended to the data to send.

'0xXXxx XX,xx-XX:xx': A sequence of hexadecimal values (range: 0x00..0xFF), that can be separated by a space, comma, dash, colon, semicolon or period, or are just entered adjecent. Only the first 2 characters should be 0x or 0X, the rest is interpreted as hex bytes, and appended to the data to send. Quotes are only required if space or comma separators are used. Using this command, either from rules, via http or mqtt, the text that is provided as content is completely sent to the serial port. No extra data is added, other than any (system) variables that are included, being replaced.

serialproxy_test,'<content to process>[,...]'

<content to process>: Some text to be processed as if it was received via the serial port.

This command is intended for testing the regular expression and filtering.

The sentence provided with this command is handed over for processing as if it was received via the serial port, so it will be processed and filtered, and an event will be generated if it’s matched.

Get Config Values

Get Config Values retrieves values or settings from the sensor or plugin, and can be used in Rules, Display plugins, Formula’s etc. The square brackets are part of the variable. Replace <taskname> by the Name of the task.

Config value

Information

[<taskname>#group,<groupnr>]

Get the contents from groupnr after processing received data.

NB: The regular expression parsen uses 0-based group numbers (where most other regex parsers use 1-based group numbers!)

[<taskname>#next,<groupvalue>]

Get the value of the next group that holds <groupvalue>.

Example:

Regular expression: ((node)=(%d+);?)((weight)=(%d+);?)((temp%d?)=(%-?%d+);?)((rssi)=(%-?%d+);?)

Received data: node=1;weight=40;temp1=20;rssi=-30

This will result in these groups:

Group

Data

0

node=1

1

node

2

1

3

weight=40

4

weight

5

40

6

temp1=20

7

temp1

8

20

9

rssi=-30

10

rssi

11

-30

Requesting [SerialProxy#next,weight] will return the value 40.

Change log

Changed in version 2.0:

added 2024-02-25 Add support for serialproxy_test command and retrieving the separate groups from parsed regex.

added 2023-03-22 Add support for writing any binary data out via the serial port.

added 2020-02-22