mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[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:
parent
104a1e5379
commit
937ccf6753
@ -167,8 +167,8 @@ public abstract class AstroThingHandler extends BaseThingHandler {
|
|||||||
*/
|
*/
|
||||||
public void publishChannelIfLinked(ChannelUID channelUID) {
|
public void publishChannelIfLinked(ChannelUID channelUID) {
|
||||||
Planet planet = getPlanet();
|
Planet planet = getPlanet();
|
||||||
if (isLinked(channelUID.getId()) && planet != null) {
|
if (isLinked(channelUID) && planet != null) {
|
||||||
final Channel channel = getThing().getChannel(channelUID.getId());
|
final Channel channel = getThing().getChannel(channelUID);
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
logger.error("Cannot find channel for {}", channelUID);
|
logger.error("Cannot find channel for {}", channelUID);
|
||||||
return;
|
return;
|
||||||
@ -272,8 +272,8 @@ public abstract class AstroThingHandler extends BaseThingHandler {
|
|||||||
private boolean isPositionalChannelLinked() {
|
private boolean isPositionalChannelLinked() {
|
||||||
List<String> positionalChannels = Arrays.asList(getPositionalChannelIds());
|
List<String> positionalChannels = Arrays.asList(getPositionalChannelIds());
|
||||||
for (Channel channel : getThing().getChannels()) {
|
for (Channel channel : getThing().getChannels()) {
|
||||||
String id = channel.getUID().getId();
|
ChannelUID id = channel.getUID();
|
||||||
if (isLinked(id) && positionalChannels.contains(id)) {
|
if (isLinked(id) && positionalChannels.contains(id.getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class AstroCommandTest {
|
|||||||
Thing thing = mock(Thing.class);
|
Thing thing = mock(Thing.class);
|
||||||
when(thing.getConfiguration()).thenReturn(thingConfiguration);
|
when(thing.getConfiguration()).thenReturn(thingConfiguration);
|
||||||
when(thing.getUID()).thenReturn(thingUID);
|
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);
|
ThingHandlerCallback callback = mock(ThingHandlerCallback.class);
|
||||||
CronScheduler cronScheduler = mock(CronScheduler.class);
|
CronScheduler cronScheduler = mock(CronScheduler.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user