mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
ESPEasy: urlEncode text for display commands
git-svn-id: https://svn.fhem.de/fhem/trunk@14045 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6e1ea4c014
commit
0d136c9e1f
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: 34_ESPEasy: urlEncode text for display commands
|
||||||
- feature: 71_PHILIPS_AUDIO: Added NP3500 support. "lvl" Reading bugfix.
|
- feature: 71_PHILIPS_AUDIO: Added NP3500 support. "lvl" Reading bugfix.
|
||||||
- change: 93_DbLog: version 2.16.5 primary key evaluation changed
|
- change: 93_DbLog: version 2.16.5 primary key evaluation changed
|
||||||
- bugfix: 32_withings: updated for new account key characters
|
- bugfix: 32_withings: updated for new account key characters
|
||||||
|
@ -36,7 +36,7 @@ use Color;
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# global/default values
|
# global/default values
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
my $module_version = 1.01; # Version of this module
|
my $module_version = 1.03; # Version of this module
|
||||||
my $minEEBuild = 128; # informational
|
my $minEEBuild = 128; # informational
|
||||||
my $minJsonVersion = 1.02; # checked in received data
|
my $minJsonVersion = 1.02; # checked in received data
|
||||||
|
|
||||||
@ -49,6 +49,9 @@ my $d_maxHttpSessions = 3; # concurrent connects to a single esp
|
|||||||
my $d_maxQueueSize = 250; # max queue size,
|
my $d_maxQueueSize = 250; # max queue size,
|
||||||
my $d_resendFailedCmd = 0; # resend failed http requests by default?
|
my $d_resendFailedCmd = 0; # resend failed http requests by default?
|
||||||
|
|
||||||
|
my $d_displayTextEncode = 1; # urlEncode Text for Displays
|
||||||
|
my $d_displayTextWidth = 0; # display width, 0 => disable formating
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# "setCmds" => "min. number of parameters"
|
# "setCmds" => "min. number of parameters"
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -214,6 +217,8 @@ sub ESPEasy_Initialize($)
|
|||||||
."colorpicker:RGB,HSV,HSVp "
|
."colorpicker:RGB,HSV,HSVp "
|
||||||
."deniedIPs "
|
."deniedIPs "
|
||||||
."disable:1,0 "
|
."disable:1,0 "
|
||||||
|
."displayTextEncode:1,0 "
|
||||||
|
."displayTextWidth "
|
||||||
."do_not_notify:0,1 "
|
."do_not_notify:0,1 "
|
||||||
."httpReqTimeout "
|
."httpReqTimeout "
|
||||||
."IODev "
|
."IODev "
|
||||||
@ -484,6 +489,9 @@ sub ESPEasy_Set($$@)
|
|||||||
return "Unknown argument $cmd, choose one of ". $clist;
|
return "Unknown argument $cmd, choose one of ". $clist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# urlEncode <text> parameter
|
||||||
|
@params = ESPEasy_urlEncodeDisplayText($hash,$cmd,@params);
|
||||||
|
|
||||||
# pin mapping (eg. D8 -> 15)
|
# pin mapping (eg. D8 -> 15)
|
||||||
my $pp = ESPEasy_paramPos($cmd,'<pin>');
|
my $pp = ESPEasy_paramPos($cmd,'<pin>');
|
||||||
if ($pp && $params[$pp-1] =~ m/^[a-zA-Z]/) {
|
if ($pp && $params[$pp-1] =~ m/^[a-zA-Z]/) {
|
||||||
@ -859,6 +867,7 @@ sub ESPEasy_Attr(@)
|
|||||||
if (defined $hash->{SUBTYPE} && $hash->{SUBTYPE} eq "bridge"
|
if (defined $hash->{SUBTYPE} && $hash->{SUBTYPE} eq "bridge"
|
||||||
&& ($aName =~ m/^(Interval|pollGPIOs|IODev|setState|readingSwitchText)$/
|
&& ($aName =~ m/^(Interval|pollGPIOs|IODev|setState|readingSwitchText)$/
|
||||||
|| $aName =~ m/^(readingPrefixGPIO|readingSuffixGPIOState|adjustValue)$/
|
|| $aName =~ m/^(readingPrefixGPIO|readingSuffixGPIOState|adjustValue)$/
|
||||||
|
|| $aName =~ m/^(displayTextEncode|displayTextWidth)$/
|
||||||
|| $aName =~ m/^(presenceCheck|parseCmdResponse|rgbGPIOs|colorpicker)$/
|
|| $aName =~ m/^(presenceCheck|parseCmdResponse|rgbGPIOs|colorpicker)$/
|
||||||
|| $aName =~ m/^(wwcwGPIOs|colorpickerCTww|colorpickerCTcw|mapLightCmds)$/)) {
|
|| $aName =~ m/^(wwcwGPIOs|colorpickerCTww|colorpickerCTcw|mapLightCmds)$/)) {
|
||||||
Log3 $name, 2, "$type $name: Attribut '$aName' can not be used by bridge";
|
Log3 $name, 2, "$type $name: Attribut '$aName' can not be used by bridge";
|
||||||
@ -875,7 +884,8 @@ sub ESPEasy_Attr(@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
elsif ($aName =~ m/^(autosave|autocreate|authentication|disable)$/
|
elsif ($aName =~ m/^(autosave|autocreate|authentication|disable)$/
|
||||||
|| $aName =~ m/^(presenceCheck|readingSwitchText|resendFailedCmd)$/) {
|
|| $aName =~ m/^(presenceCheck|readingSwitchText|resendFailedCmd)$/
|
||||||
|
|| $aName =~ m/^(displayTextEncode)$/) {
|
||||||
$ret = "0,1" if ($cmd eq "set" && not $aVal =~ m/^(0|1)$/)}
|
$ret = "0,1" if ($cmd eq "set" && not $aVal =~ m/^(0|1)$/)}
|
||||||
|
|
||||||
elsif ($aName eq "combineDevices") {
|
elsif ($aName eq "combineDevices") {
|
||||||
@ -912,6 +922,10 @@ sub ESPEasy_Attr(@)
|
|||||||
$ret = "integer"
|
$ret = "integer"
|
||||||
if ($cmd eq "set" && not $aVal =~ m/^(\d+)$/)}
|
if ($cmd eq "set" && not $aVal =~ m/^(\d+)$/)}
|
||||||
|
|
||||||
|
elsif ($aName eq "displayTextWidth") {
|
||||||
|
$ret = "number of charaters per line"
|
||||||
|
if ($cmd eq "set" && not $aVal =~ m/^(\d+)$/)}
|
||||||
|
|
||||||
elsif ($aName eq "readingPrefixGPIO") {
|
elsif ($aName eq "readingPrefixGPIO") {
|
||||||
$ret = "[a-zA-Z0-9._-/]+"
|
$ret = "[a-zA-Z0-9._-/]+"
|
||||||
if ($cmd eq "set" && $aVal !~ m/^[A-Za-z\d_\.\-\/]+$/)}
|
if ($cmd eq "set" && $aVal !~ m/^[A-Za-z\d_\.\-\/]+$/)}
|
||||||
@ -2042,6 +2056,47 @@ sub ESPEasy_adjustValue($$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
sub ESPEasy_urlEncodeDisplayText($$@)
|
||||||
|
{
|
||||||
|
my ($hash, $cmd, @params) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my $enc = AttrVal($name, "displayTextEncode", $d_displayTextEncode);
|
||||||
|
my $pp = ESPEasy_paramPos($cmd,'<text>');
|
||||||
|
|
||||||
|
if ($enc && $pp) {
|
||||||
|
my (@p, @t);
|
||||||
|
my $c = scalar @params;
|
||||||
|
|
||||||
|
# leading parameters
|
||||||
|
for (my $i=0; $i<$pp-1; $i++) {
|
||||||
|
push( @p, $params[$i] )
|
||||||
|
}
|
||||||
|
|
||||||
|
# collect all texts parameters
|
||||||
|
for (my $i=$pp-1; $i<$c; $i++) {
|
||||||
|
$params[$i] =~ s/,/./g; # comma is http url parameter splitter
|
||||||
|
#$params[$i] =~ s/[\x00-\x1F\x7F-\xFF]//g; # remove non-printable chrs
|
||||||
|
push( @t, $params[$i] )
|
||||||
|
}
|
||||||
|
my $text = join(" ", @t);
|
||||||
|
|
||||||
|
# fill line with leading/trailing spaces
|
||||||
|
my $width = AttrVal($name,"displayTextWidth", $d_displayTextWidth);
|
||||||
|
if ($width) {
|
||||||
|
$text = " " x ($p[1]-1) .$text. " " x ($width - length($text) - $p[1]+1);
|
||||||
|
$text = substr($text, 0, $width);
|
||||||
|
$p[1] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
push(@p, urlEncode($text));
|
||||||
|
return @p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return @params;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
sub ESPEasy_isPmInstalled($$)
|
sub ESPEasy_isPmInstalled($$)
|
||||||
{
|
{
|
||||||
@ -2852,7 +2907,7 @@ sub ESPEasy_removeGit($)
|
|||||||
</ul>
|
</ul>
|
||||||
Default: none<br>
|
Default: none<br>
|
||||||
Eg. <code>attr ESPxx adjustValue humidity:+0.1
|
Eg. <code>attr ESPxx adjustValue humidity:+0.1
|
||||||
temperature+*:($VALUE-32)*5/9</code><br>
|
temperature*:($VALUE-32)*5/9</code><br>
|
||||||
Eg. <code>attr ESPxx adjustValue
|
Eg. <code>attr ESPxx adjustValue
|
||||||
.*:my_OwnFunction($NAME,$READING,$VALUE)</code><br>
|
.*:my_OwnFunction($NAME,$READING,$VALUE)</code><br>
|
||||||
<br>
|
<br>
|
||||||
@ -2884,6 +2939,22 @@ sub ESPEasy_removeGit($)
|
|||||||
Possible values: 0,1<br>
|
Possible values: 0,1<br>
|
||||||
Default: 0</li><br>
|
Default: 0</li><br>
|
||||||
|
|
||||||
|
<li><a name="ESPEasy_displayTextEncode">displayTextEncode</a><br>
|
||||||
|
Used to disable url encoding for text that is send to oled/lcd displays.
|
||||||
|
Useful if you want to encode the text by yourself.<br>
|
||||||
|
Possible values: 0,1<br>
|
||||||
|
Default: 1 (enabled)</li><br>
|
||||||
|
|
||||||
|
<li><a name="ESPEasy_displayTextWidth">displayTextWidth</a><br>
|
||||||
|
Used to specify number of characters per display line.<br>
|
||||||
|
If set then all characters before and after the text on the same line will
|
||||||
|
be overwritten with spaces. Attribute
|
||||||
|
<a href="#ESPEasy_displayTextEncode">displayTextEncode</a> must not be
|
||||||
|
disabled to use this feature. A 128x64px display has 16 characters per
|
||||||
|
line if you are using a 8px font.<br>
|
||||||
|
Possible values: integer<br>
|
||||||
|
Default: 0 (disabled)</li><br>
|
||||||
|
|
||||||
<li><a name="ESPEasy_Interval">Interval</a><br>
|
<li><a name="ESPEasy_Interval">Interval</a><br>
|
||||||
Used to set polling interval for presence check and GPIOs polling in
|
Used to set polling interval for presence check and GPIOs polling in
|
||||||
seconds. 0 will disable this feature.<br>
|
seconds. 0 will disable this feature.<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user