22
22
import java .nio .ByteBuffer ;
23
23
import java .util .Map ;
24
24
import java .util .Map .Entry ;
25
+ import java .util .Objects ;
25
26
import java .util .concurrent .ScheduledFuture ;
26
27
import java .util .concurrent .TimeUnit ;
27
28
32
33
import javax .measure .quantity .Power ;
33
34
import javax .measure .quantity .Time ;
34
35
35
- import org .apache .commons .lang3 .StringUtils ;
36
36
import org .openhab .binding .keba .internal .KebaBindingConstants .KebaSeries ;
37
37
import org .openhab .binding .keba .internal .KebaBindingConstants .KebaType ;
38
38
import org .openhab .core .cache .ExpiringCacheMap ;
51
51
import org .openhab .core .types .Command ;
52
52
import org .openhab .core .types .RefreshType ;
53
53
import org .openhab .core .types .State ;
54
+ import org .openhab .core .util .StringUtils ;
54
55
import org .slf4j .Logger ;
55
56
import org .slf4j .LoggerFactory ;
56
57
@@ -237,7 +238,7 @@ protected void onData(ByteBuffer byteBuffer) {
237
238
}
238
239
239
240
String response = new String (byteBuffer .array (), 0 , byteBuffer .limit ());
240
- response = StringUtils .chomp (response );
241
+ response = Objects . requireNonNull ( StringUtils .chomp (response ) );
241
242
242
243
if (response .contains ("TCH-OK" )) {
243
244
// ignore confirmation messages which are not JSON
@@ -529,7 +530,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
529
530
switch (channelUID .getId ()) {
530
531
case CHANNEL_MAX_PRESET_CURRENT : {
531
532
if (command instanceof QuantityType <?> quantityCommand ) {
532
- QuantityType <?> value = quantityCommand .toUnit ("mA" );
533
+ QuantityType <?> value = Objects . requireNonNull ( quantityCommand .toUnit ("mA" ) );
533
534
534
535
transceiver .send ("curr " + Math .min (Math .max (6000 , value .intValue ()), maxSystemCurrent ), this );
535
536
}
@@ -548,7 +549,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
548
549
} else if (command == OnOffType .OFF ) {
549
550
newValue = 6000 ;
550
551
} else if (command instanceof QuantityType <?> quantityCommand ) {
551
- QuantityType <?> value = quantityCommand .toUnit ("%" );
552
+ QuantityType <?> value = Objects . requireNonNull ( quantityCommand .toUnit ("%" ) );
552
553
newValue = Math .round (6000 + (maxSystemCurrent - 6000 ) * value .doubleValue () / 100.0 );
553
554
} else {
554
555
return ;
@@ -595,7 +596,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
595
596
}
596
597
case CHANNEL_SETENERGY : {
597
598
if (command instanceof QuantityType <?> quantityCommand ) {
598
- QuantityType <?> value = quantityCommand .toUnit (Units .WATT_HOUR );
599
+ QuantityType <?> value = Objects . requireNonNull ( quantityCommand .toUnit (Units .WATT_HOUR ) );
599
600
transceiver .send (
600
601
"setenergy " + Math .min (Math .max (0 , Math .round (value .doubleValue () * 10.0 )), 999999999 ),
601
602
this );
0 commit comments