[doorbird] Warning and SAT cleanup (#15824)

* Warning and SAT clenaup

---------

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2023-11-04 10:31:52 +01:00 committed by GitHub
parent 0a5a9912a5
commit 6efa3d792c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 7 deletions

View File

@ -54,6 +54,7 @@ public class DoorbirdActions implements ThingActions {
@RuleAction(label = "restart the Doorbird", description = "Restarts the Doorbird device.")
public void restart() {
logger.debug("Doorbird action 'restart' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
handler.actionRestart();
} else {
@ -68,6 +69,7 @@ public class DoorbirdActions implements ThingActions {
@RuleAction(label = "hangup a SIP call", description = "Hangup SIP call.")
public void sipHangup() {
logger.debug("Doorbird action 'sipHangup' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
handler.actionSIPHangup();
} else {
@ -82,6 +84,7 @@ public class DoorbirdActions implements ThingActions {
@RuleAction(label = "get the ring time limit", description = "Get the value of RING_TIME_LIMIT.")
public @ActionOutput(name = "getRingTimeLimit", type = "java.lang.String") String getRingTimeLimit() {
logger.debug("Doorbird action 'getRingTimeLimit' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetRingTimeLimit();
} else {
@ -97,6 +100,7 @@ public class DoorbirdActions implements ThingActions {
@RuleAction(label = "get the call time limit", description = "Get the value of CALL_TIME_LIMIT.")
public @ActionOutput(name = "getCallTimeLimit", type = "java.lang.String") String getCallTimeLimit() {
logger.debug("Doorbird action 'getCallTimeLimit' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetCallTimeLimit();
} else {
@ -112,6 +116,7 @@ public class DoorbirdActions implements ThingActions {
@RuleAction(label = "get the last error code", description = "Get the value of LASTERRORCODE.")
public @ActionOutput(name = "getLastErrorCode", type = "java.lang.String") String getLastErrorCode() {
logger.debug("Doorbird action 'getLastErrorCode' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetLastErrorCode();
} else {
@ -127,6 +132,7 @@ public class DoorbirdActions implements ThingActions {
@RuleAction(label = "get the last error text", description = "Get the value of LASTERRORTEXT.")
public @ActionOutput(name = "getLastErrorText", type = "java.lang.String") String getLastErrorText() {
logger.debug("Doorbird action 'getLastErrorText' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetLastErrorText();
} else {

View File

@ -54,6 +54,7 @@ public final class DoorbirdAPI {
private static final Gson GSON = new Gson();
private final Logger logger = LoggerFactory.getLogger(DoorbirdAPI.class);
private static final int CHUNK_SIZE = 256;
private @Nullable Authorization authorization;
private @Nullable HttpClient httpClient;
@ -191,7 +192,6 @@ public final class DoorbirdAPI {
// It is crucial to send data in small chunks to not overload the doorbird
// It means that we have to wait the appropriate amount of time between chunk to send
// real time data, as if it were live spoken.
int CHUNK_SIZE = 256;
int nbByteRead = -1;
long nextChunkSendTimeStamp = 0;
do {

View File

@ -365,9 +365,10 @@ public class DoorbellHandler extends BaseThingHandler {
}
private void stopImageRefreshJob() {
ScheduledFuture<?> imageRefreshJob = this.imageRefreshJob;
if (imageRefreshJob != null) {
imageRefreshJob.cancel(true);
imageRefreshJob = null;
this.imageRefreshJob = null;
logger.debug("Canceling image refresh job");
}
}
@ -378,9 +379,11 @@ public class DoorbellHandler extends BaseThingHandler {
}
private void stopUDPListenerJob() {
ScheduledFuture<?> listenerJob = this.listenerJob;
if (listenerJob != null) {
listenerJob.cancel(true);
udpListener.shutdown();
this.listenerJob = null;
logger.debug("Canceling listener job");
}
}
@ -390,19 +393,21 @@ public class DoorbellHandler extends BaseThingHandler {
if (offDelay == null) {
return;
}
ScheduledFuture<?> doorbellOffJob = this.doorbellOffJob;
if (doorbellOffJob != null) {
doorbellOffJob.cancel(true);
}
doorbellOffJob = scheduler.schedule(() -> {
this.doorbellOffJob = scheduler.schedule(() -> {
logger.debug("Update channel 'doorbell' to OFF for thing {}", getThing().getUID());
triggerChannel(CHANNEL_DOORBELL, CommonTriggerEvents.RELEASED);
}, offDelay, TimeUnit.SECONDS);
}
private void stopDoorbellOffJob() {
ScheduledFuture<?> doorbellOffJob = this.doorbellOffJob;
if (doorbellOffJob != null) {
doorbellOffJob.cancel(true);
doorbellOffJob = null;
this.doorbellOffJob = null;
logger.debug("Canceling doorbell off job");
}
}
@ -412,19 +417,21 @@ public class DoorbellHandler extends BaseThingHandler {
if (offDelay == null) {
return;
}
ScheduledFuture<?> motionOffJob = this.motionOffJob;
if (motionOffJob != null) {
motionOffJob.cancel(true);
}
motionOffJob = scheduler.schedule(() -> {
this.motionOffJob = scheduler.schedule(() -> {
logger.debug("Update channel 'motion' to OFF for thing {}", getThing().getUID());
updateState(CHANNEL_MOTION, OnOffType.OFF);
}, offDelay, TimeUnit.SECONDS);
}
private void stopMotionOffJob() {
ScheduledFuture<?> motionOffJob = this.motionOffJob;
if (motionOffJob != null) {
motionOffJob.cancel(true);
motionOffJob = null;
this.motionOffJob = null;
logger.debug("Canceling motion off job");
}
}

View File

@ -66,10 +66,11 @@ public class DoorbirdUdpListener extends Thread {
}
public void shutdown() {
DatagramSocket socket = this.socket;
if (socket != null) {
socket.close();
logger.debug("Listener closing listener socket");
socket = null;
this.socket = null;
}
}