FIX: fixed not working without authentication
This commit is contained in:
parent
fc04cea1b5
commit
8490e7046f
@ -165,9 +165,17 @@ sub NTFY_newSubscription
|
|||||||
my $topic = shift;
|
my $topic = shift;
|
||||||
|
|
||||||
my $newDeviceName = makeDeviceName($hash->{NAME} . "_" . $topic);
|
my $newDeviceName = makeDeviceName($hash->{NAME} . "_" . $topic);
|
||||||
my $token = NFTY_Calc_Auth_Token($hash->{helper}->{PASSWORD},$hash->{USERNAME});
|
|
||||||
|
|
||||||
fhem("define $newDeviceName NTFY_TOPIC " . $hash->{SERVER} . " " . $token . " " . $topic);
|
my $token;
|
||||||
|
if ($hash->{helper}->{PASSWORD})
|
||||||
|
{
|
||||||
|
$token= NFTY_Calc_Auth_Token($hash->{helper}->{PASSWORD},$hash->{USERNAME});
|
||||||
|
fhem("define $newDeviceName NTFY_TOPIC " . $hash->{SERVER} . " " . $token . " " . $topic);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fhem("define $newDeviceName NTFY_TOPIC " . $hash->{SERVER} . " " . $topic);
|
||||||
|
}
|
||||||
|
|
||||||
NTFY_Update_Subscriptions_Readings($hash);
|
NTFY_Update_Subscriptions_Readings($hash);
|
||||||
}
|
}
|
||||||
|
@ -100,12 +100,25 @@ sub NTFY_TOPIC_Define
|
|||||||
# parse parameters into array and hash
|
# parse parameters into array and hash
|
||||||
my($params, $h) = parseParams($define);
|
my($params, $h) = parseParams($define);
|
||||||
|
|
||||||
|
my $token;
|
||||||
|
my $topic;
|
||||||
|
|
||||||
|
if ($params->[4])
|
||||||
|
{
|
||||||
|
$topic = $params->[4];
|
||||||
|
$token = $params->[3]
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic = $params->[3];
|
||||||
|
}
|
||||||
|
|
||||||
my $name = makeDeviceName($params->[0]);
|
my $name = makeDeviceName($params->[0]);
|
||||||
|
|
||||||
$hash->{NAME} = $name;
|
$hash->{NAME} = $name;
|
||||||
$hash->{SERVER} = $params->[2];
|
$hash->{SERVER} = $params->[2];
|
||||||
$hash->{helper}{authString} = $params->[3];
|
$hash->{helper}{authString} = $token;
|
||||||
$hash->{TOPIC} = $params->[4];
|
$hash->{TOPIC} = $topic;
|
||||||
$hash->{Clients} = "NTFY_CLIENT";
|
$hash->{Clients} = "NTFY_CLIENT";
|
||||||
$hash->{ClientsKeepOrder} = 1;
|
$hash->{ClientsKeepOrder} = 1;
|
||||||
$hash->{STATE} = "unknown";
|
$hash->{STATE} = "unknown";
|
||||||
|
Loading…
Reference in New Issue
Block a user