Skip to content

Commit

Permalink
Astro binding: fix issue #1240 (#1246)
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and kaikreuzer committed Sep 20, 2016
1 parent 7e54ced commit a9ae5d5
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -245,6 +245,7 @@ private void stopJobs() {
@Override
public void channelLinked(ChannelUID channelUID) {
linkedChannelChange(channelUID, 1);
publishChannelIfLinked(channelUID);
}

@Override
Expand Down

0 comments on commit a9ae5d5

Please sign in to comment.