mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
30_MilightBridge: Specify port in define
git-svn-id: https://svn.fhem.de/fhem/trunk@11710 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
f00fd8cf5d
commit
809626e251
@ -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.
|
||||||
|
- changed: 30_MilightBridge: Specify port in define
|
||||||
- changed: 31_HUEDevice: allow toggle command for unreachble devices
|
- changed: 31_HUEDevice: allow toggle command for unreachble devices
|
||||||
new ignoreReachable attribute
|
new ignoreReachable attribute
|
||||||
- update: 77_UWZ: New Minor Release 1.2 Support for United Kingdom
|
- update: 77_UWZ: New Minor Release 1.2 Support for United Kingdom
|
||||||
|
@ -46,6 +46,7 @@ sub MilightBridge_Initialize($)
|
|||||||
#Consumer
|
#Consumer
|
||||||
$hash->{DefFn} = "MilightBridge_Define";
|
$hash->{DefFn} = "MilightBridge_Define";
|
||||||
$hash->{UndefFn} = "MilightBridge_Undefine";
|
$hash->{UndefFn} = "MilightBridge_Undefine";
|
||||||
|
$hash->{NOTIFYDEV} = "global";
|
||||||
$hash->{NotifyFn} = "MilightBridge_Notify";
|
$hash->{NotifyFn} = "MilightBridge_Notify";
|
||||||
$hash->{AttrFn} = "MilightBridge_Attr";
|
$hash->{AttrFn} = "MilightBridge_Attr";
|
||||||
$hash->{AttrList} = "port protocol:udp,tcp sendInterval disable:0,1 tcpPing:1 checkInterval ".$readingFnAttributes;
|
$hash->{AttrList} = "port protocol:udp,tcp sendInterval disable:0,1 tcpPing:1 checkInterval ".$readingFnAttributes;
|
||||||
@ -60,7 +61,7 @@ sub MilightBridge_Define($$)
|
|||||||
my ($hash, $def) = @_;
|
my ($hash, $def) = @_;
|
||||||
my @args = split("[ \t][ \t]*", $def);
|
my @args = split("[ \t][ \t]*", $def);
|
||||||
|
|
||||||
return "Usage: define <name> MilightBridge <host/ip>" if(@args < 3);
|
return "Usage: define <name> MilightBridge <host/ip:port>" if(@args < 3);
|
||||||
|
|
||||||
my ($name, $type, $host) = @args;
|
my ($name, $type, $host) = @args;
|
||||||
|
|
||||||
@ -68,11 +69,12 @@ sub MilightBridge_Define($$)
|
|||||||
my %matchList = ( "1:MilightDevice" => ".*" );
|
my %matchList = ( "1:MilightDevice" => ".*" );
|
||||||
$hash->{MatchList} = \%matchList;
|
$hash->{MatchList} = \%matchList;
|
||||||
|
|
||||||
|
my ($host, $port) = split(":", $host);
|
||||||
# Parameters
|
# Parameters
|
||||||
$hash->{HOST} = $host;
|
$hash->{HOST} = $host;
|
||||||
# Set Port (Default 8899, old bridge (V2) uses 50000
|
# Set Port (Default 8899, old bridge (V2) uses 50000
|
||||||
$attr{$name}{"port"} = "8899" if (!defined($attr{$name}{"port"}));
|
$port = "8899" if (!defined($port));
|
||||||
$hash->{PORT} = $attr{$name}{"port"};
|
$hash->{PORT} = $port;
|
||||||
|
|
||||||
$attr{$name}{"protocol"} = "udp" if (!defined($attr{$name}{"protocol"}));
|
$attr{$name}{"protocol"} = "udp" if (!defined($attr{$name}{"protocol"}));
|
||||||
|
|
||||||
@ -157,19 +159,6 @@ sub MilightBridge_Attr($$$$) {
|
|||||||
readingsSingleUpdate($hash, "state", "Initialized", 1);
|
readingsSingleUpdate($hash, "state", "Initialized", 1);
|
||||||
MilightBridge_SetNextTimer($hash);
|
MilightBridge_SetNextTimer($hash);
|
||||||
}
|
}
|
||||||
elsif ($attribute eq "port")
|
|
||||||
{
|
|
||||||
if (($value !~ /^\d*$/) || ($value < 1))
|
|
||||||
{
|
|
||||||
$attr{$name}{"port"} = 100;
|
|
||||||
$hash->{PORT} = $attr{$name}{"port"};
|
|
||||||
return "port is required as numeric (default: 8899)";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$hash->{PORT} = $attr{$name}{"port"};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ($attribute eq "protocol")
|
elsif ($attribute eq "protocol")
|
||||||
{
|
{
|
||||||
if (($value eq "tcp" || $value eq "udp"))
|
if (($value eq "tcp" || $value eq "udp"))
|
||||||
@ -206,9 +195,6 @@ sub MilightBridge_Attr($$$$) {
|
|||||||
sub MilightBridge_Notify($$)
|
sub MilightBridge_Notify($$)
|
||||||
{
|
{
|
||||||
my ($hash,$dev) = @_;
|
my ($hash,$dev) = @_;
|
||||||
Log3 ($hash, 5, "$hash->{NAME}_Notify: Triggered by $dev->{NAME}; @{$dev->{CHANGED}}");
|
|
||||||
|
|
||||||
return if($dev->{NAME} ne "global");
|
|
||||||
|
|
||||||
if(grep(m/^(INITIALIZED|REREADCFG|DEFINED.*|MODIFIED.*|DELETED.*)$/, @{$dev->{CHANGED}}))
|
if(grep(m/^(INITIALIZED|REREADCFG|DEFINED.*|MODIFIED.*|DELETED.*)$/, @{$dev->{CHANGED}}))
|
||||||
{
|
{
|
||||||
@ -225,7 +211,10 @@ sub MilightBridge_SetNextTimer($)
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
# Check state every X seconds
|
# Check state every X seconds
|
||||||
RemoveInternalTimer($hash);
|
RemoveInternalTimer($hash);
|
||||||
InternalTimer(gettimeofday() + AttrVal($hash->{NAME}, "checkInterval", "10"), "MilightBridge_DoPingStart", $hash, 0);
|
my $interval=AttrVal($hash->{NAME}, "checkInterval", "10");
|
||||||
|
if ($interval > 0) {
|
||||||
|
InternalTimer(gettimeofday() + $interval, "MilightBridge_DoPingStart", $hash, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -456,9 +445,9 @@ sub MilightBridge_CmdQueue_Send(@)
|
|||||||
<a name="MilightBridge_define"></a>
|
<a name="MilightBridge_define"></a>
|
||||||
<p><b>Define</b></p>
|
<p><b>Define</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<p><code>define <name> MilightBridge <host/ip></code></p>
|
<p><code>define <name> MilightBridge <host/ip:port></code></p>
|
||||||
<p>Specifies the MilightBridge device.<br/>
|
<p>Specifies the MilightBridge device.<br/>
|
||||||
<host/ip> is the hostname or IP address of the Bridge.</p>
|
<host/ip> is the hostname or IP address of the Bridge with optional port (defaults to 8899 if not defined, use 50000 for V1,V2 bridges)</p>
|
||||||
</ul>
|
</ul>
|
||||||
<a name="MilightBridge_readings"></a>
|
<a name="MilightBridge_readings"></a>
|
||||||
<p><b>Readings</b></p>
|
<p><b>Readings</b></p>
|
||||||
@ -488,10 +477,6 @@ sub MilightBridge_CmdQueue_Send(@)
|
|||||||
Default: 10s. Time after the bridge connection is re-checked.<br>
|
Default: 10s. Time after the bridge connection is re-checked.<br>
|
||||||
If this is set to 0 checking is disabled and state = "Initialized".
|
If this is set to 0 checking is disabled and state = "Initialized".
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<b>port</b><br/>
|
|
||||||
Default: 8899. Older bridges (V2) used port 50000 so change this value if you have an old bridge.
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<b>protocol</b><br/>
|
<b>protocol</b><br/>
|
||||||
Default: udp. Change to tcp if you have enabled tcp mode on your bridge.
|
Default: udp. Change to tcp if you have enabled tcp mode on your bridge.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user