From a9ae5d5ad94a7ff7fcb220ed8ebaef3df663bd91 Mon Sep 17 00:00:00 2001 From: lolodomo Date: Tue, 20 Sep 2016 07:54:21 +0200 Subject: [PATCH] Astro binding: fix issue #1240 (#1246) Signed-off-by: Laurent Garnier --- .../binding/astro/handler/AstroThingHandler.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/binding/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/handler/AstroThingHandler.java b/addons/binding/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/handler/AstroThingHandler.java index 80d272c7631f9..90c7c4ac76ac6 100644 --- a/addons/binding/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/handler/AstroThingHandler.java +++ b/addons/binding/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/handler/AstroThingHandler.java @@ -122,7 +122,7 @@ public void dispose() { public void handleCommand(ChannelUID channelUID, Command command) { if (RefreshType.REFRESH == command) { logger.debug("Refreshing {}", channelUID); - publishChannelIfLinked(getThing().getChannel(channelUID.getId())); + publishChannelIfLinked(channelUID); } else { logger.warn("The Astro-Binding is a read-only binding and can not handle commands"); } @@ -143,19 +143,19 @@ public void handleUpdate(ChannelUID channelUID, State newState) { protected void publishPlanet() { logger.debug("Publishing planet {} for thing {}", getPlanet().getClass().getSimpleName(), getThing().getUID()); for (Channel channel : getThing().getChannels()) { - publishChannelIfLinked(channel); + publishChannelIfLinked(channel.getUID()); } } /** * Publishes the channel with data if it's linked. */ - private void publishChannelIfLinked(Channel channel) { - if (isLinked(channel.getUID().getId()) && getPlanet() != null) { + private void publishChannelIfLinked(ChannelUID channelUID) { + if (isLinked(channelUID.getId()) && getPlanet() != null) { try { - updateState(channel.getUID(), PropertyUtils.getState(channel.getUID(), getPlanet())); + updateState(channelUID, PropertyUtils.getState(channelUID, getPlanet())); } catch (Exception ex) { - logger.error("Can't update state for channel " + channel.getUID() + ": " + ex.getMessage(), ex); + logger.error("Can't update state for channel " + channelUID + ": " + ex.getMessage(), ex); } } } @@ -245,6 +245,7 @@ private void stopJobs() { @Override public void channelLinked(ChannelUID channelUID) { linkedChannelChange(channelUID, 1); + publishChannelIfLinked(channelUID); } @Override