|
|
## [HoBo.pm](https://gl.petatech.eu/root/HomeBot/-/blob/master/lib/HoBo.pm)
|
|
|
|
|
|
Defines maximum length for a Readingname (MAXLEN_RN) and for a Device name (MAXLEN_DN).
|
|
|
|
|
|
### goodDeviceName
|
|
|
|
|
|
### goodReadingName
|
|
|
|
|
|
```perl
|
|
|
$valid = goodReadingName($name);
|
|
|
```
|
|
|
This function checks if *Readingname* `$name` is a valid format which consists of
|
|
|
This function checks if *Readingname* `$name` is a valid format which means up to MAXLEN:RN and consisting of any UTF-8 character except
|
|
|
|
|
|
* upper and lowercase letters [a-zA-Z]
|
|
|
* digits [0-9]
|
|
|
* underscore `_`
|
|
|
* minus `-`
|
|
|
* dot `.`
|
|
|
* slash `/`
|
|
|
* whitespace (`\s`)
|
|
|
|
|
|
If the identifier starts with a dot `.`, it's considered to be an internal identifier and is treated differently in visualization, i.e. hidden.
|
|
|
If the identifier starts with a dot `.`, it's considered to be an internal identifier and is treated differently in visualization, i.e. hidden. The leading `.` is not included in MAXLEN_RN length considerations.
|
|
|
|
|
|
For valid identifiers a true value is returned, false otherwise. This function can be used in if-constructs directly to test whether a *Readingname* is valid or not.
|
|
|
|
|
|
TODO:
|
|
|
|
|
|
Clarify if
|
|
|
|
|
|
```
|
|
|
...
|
|
|
.ätschbätsch
|
|
|
///
|
|
|
-aha-
|
|
|
```
|
|
|
|
|
|
are valid names, because in original FHEM code, they are which is probably a bug.
|
|
|
### makeDeviceName
|
|
|
|
|
|
### makeReadingName
|
|
|
|
|
|
```perl
|
|
|
$validName = makeReadingName($name);
|
|
|
```
|
|
|
This function removes from given Readingname `$name` all invalid characters and replaces them with the underscore `_`. The return value `$validName` is a Readingname that has only valid characters in it (see `goodReadingName`).
|
|
|
This function removes from given Readingname `$name` all invalid characters and replaces them with the underscore `_`. Also, if the Readingname is longer than MAXLEN_RN it is pruned to this maximum length. The return value `$validName` is a Readingname that has only valid characters in it (see `goodReadingName`).
|
|
|
If `$name` was already valid, `$validName` equals `$name`.
|
|
|
|