[astro] Use the existing ChannelUID instance to check the linked state (#17126)

Signed-off-by: Jörg Sautter <joerg.sautter@gmx.net>
This commit is contained in:
joerg1985 2024-07-23 21:55:14 +02:00 committed by GitHub
parent 104a1e5379
commit 937ccf6753
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -167,8 +167,8 @@ public abstract class AstroThingHandler extends BaseThingHandler {
*/
public void publishChannelIfLinked(ChannelUID channelUID) {
Planet planet = getPlanet();
if (isLinked(channelUID.getId()) && planet != null) {
final Channel channel = getThing().getChannel(channelUID.getId());
if (isLinked(channelUID) && planet != null) {
final Channel channel = getThing().getChannel(channelUID);
if (channel == null) {
logger.error("Cannot find channel for {}", channelUID);
return;
@ -272,8 +272,8 @@ public abstract class AstroThingHandler extends BaseThingHandler {
private boolean isPositionalChannelLinked() {
List<String> positionalChannels = Arrays.asList(getPositionalChannelIds());
for (Channel channel : getThing().getChannels()) {
String id = channel.getUID().getId();
if (isLinked(id) && positionalChannels.contains(id)) {
ChannelUID id = channel.getUID();
if (isLinked(id) && positionalChannels.contains(id.getId())) {
return true;
}
}

View File

@ -59,7 +59,7 @@ public class AstroCommandTest {
Thing thing = mock(Thing.class);
when(thing.getConfiguration()).thenReturn(thingConfiguration);
when(thing.getUID()).thenReturn(thingUID);
when(thing.getChannel(DEFAULT_TEST_CHANNEL_ID)).thenReturn(channel);
when(thing.getChannel(channelUID)).thenReturn(channel);
ThingHandlerCallback callback = mock(ThingHandlerCallback.class);
CronScheduler cronScheduler = mock(CronScheduler.class);