Skip to content

Commit

Permalink
Merge pull request openhab#1482 from mod42/master
Browse files Browse the repository at this point in the history
Fritzbox Binding log message openhab#881
  • Loading branch information
teichsta committed Oct 14, 2014
2 parents 46f0fc6 + d08419d commit bf9cd3d
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void deactivate() {
@Override
public void internalReceiveCommand(String itemName, Command command) {

if (password != null) {
if (password != null && !password.isEmpty()) {
String type = null;
for (FritzboxBindingProvider provider : providers) {
type = provider.getType(itemName);
Expand Down Expand Up @@ -575,13 +575,14 @@ public void execute(JobExecutionContext arg0)
@Override
protected void execute() {

if (password == null)
return;
else if (password.trim().isEmpty())
return;

try {
TelnetClient client = new TelnetClient();
client.connect(ip);

receive(client);
send(client, password);
receive(client);
TelnetClient client = null ;


for (FritzboxBindingProvider provider : providers) {
for (String item : provider.getItemNames()) {
Expand All @@ -598,6 +599,14 @@ protected void execute() {
}else
continue;

if (client == null){
client = new TelnetClient();
client.connect(ip);
receive(client);
send(client, password);
receive(client);
}

send(client, query);

String answer = receive(client);
Expand Down Expand Up @@ -627,10 +636,10 @@ protected void execute() {

}
}

client.disconnect();
if (client != null)
client.disconnect();
} catch (Exception e) {
logger.warn("Could not get item state", e);
logger.warn("Could not get item state ", e);
}

}
Expand Down

0 comments on commit bf9cd3d

Please sign in to comment.