mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-04 03:14:07 +01:00
[freeboxos] Avoid useless API requests (phone) (#17310)
Avoids API requests when channels are unlinked. Signed-off-by: Laurent Garnier <lg.hc@free.fr> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
f9bb540662
commit
5e84f650f8
@ -36,6 +36,19 @@ public class DectHandler extends FxsHandler {
|
|||||||
super(thing);
|
super(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void internalPoll() throws FreeboxException {
|
||||||
|
if (isLinked(TELEPHONY_SERVICE) || isLinked(DECT_ACTIVE) || isLinked(ALTERNATE_RING)) {
|
||||||
|
Config config = getManager(PhoneManager.class).getConfig();
|
||||||
|
updateConfigChannels(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLinked(ONHOOK) || isLinked(RINGING) || isLinked(HARDWARE_STATUS) || isLinked(GAIN_RX)
|
||||||
|
|| isLinked(GAIN_TX)) {
|
||||||
|
getManager(PhoneManager.class).getStatus(getClientId()).ifPresent(this::updateStatusChannels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateConfigChannels(Config config) {
|
protected void updateConfigChannels(Config config) {
|
||||||
super.updateConfigChannels(config);
|
super.updateConfigChannels(config);
|
||||||
|
@ -23,7 +23,6 @@ import org.openhab.binding.freeboxos.internal.api.rest.PhoneManager.Config;
|
|||||||
import org.openhab.binding.freeboxos.internal.api.rest.PhoneManager.Status;
|
import org.openhab.binding.freeboxos.internal.api.rest.PhoneManager.Status;
|
||||||
import org.openhab.core.library.types.OnOffType;
|
import org.openhab.core.library.types.OnOffType;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
import org.openhab.core.thing.ThingStatus;
|
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -52,10 +51,14 @@ public class FxsHandler extends ApiConsumerHandler {
|
|||||||
protected void internalPoll() throws FreeboxException {
|
protected void internalPoll() throws FreeboxException {
|
||||||
logger.debug("Polling landline status...");
|
logger.debug("Polling landline status...");
|
||||||
|
|
||||||
Config config = getManager(PhoneManager.class).getConfig();
|
if (isLinked(TELEPHONY_SERVICE)) {
|
||||||
updateConfigChannels(config);
|
Config config = getManager(PhoneManager.class).getConfig();
|
||||||
|
updateConfigChannels(config);
|
||||||
|
}
|
||||||
|
|
||||||
getManager(PhoneManager.class).getStatus(getClientId()).ifPresent(this::updateStatusChannels);
|
if (isLinked(ONHOOK) || isLinked(RINGING) || isLinked(HARDWARE_STATUS)) {
|
||||||
|
getManager(PhoneManager.class).getStatus(getClientId()).ifPresent(this::updateStatusChannels);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateConfigChannels(Config config) {
|
protected void updateConfigChannels(Config config) {
|
||||||
@ -66,7 +69,6 @@ public class FxsHandler extends ApiConsumerHandler {
|
|||||||
updateChannelOnOff(ONHOOK, status.onHook());
|
updateChannelOnOff(ONHOOK, status.onHook());
|
||||||
updateChannelOnOff(RINGING, status.isRinging());
|
updateChannelOnOff(RINGING, status.isRinging());
|
||||||
updateChannelString(HARDWARE_STATUS, status.hardwareDefect() ? "KO" : "OK");
|
updateChannelString(HARDWARE_STATUS, status.hardwareDefect() ? "KO" : "OK");
|
||||||
updateStatus(ThingStatus.ONLINE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user