[feed] added channel for enclosure link on latest entry (#11345)
Signed-off-by: Juergen Pabel <juergen@pabel.net>
This commit is contained in:
@@ -20,6 +20,7 @@ import org.openhab.core.thing.ThingTypeUID;
|
||||
* used across the whole binding.
|
||||
*
|
||||
* @author Svilen Valkanov - Initial contribution
|
||||
* @author Juergen Pabel - Added enclosure channel
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class FeedBindingConstants {
|
||||
@@ -50,6 +51,11 @@ public class FeedBindingConstants {
|
||||
*/
|
||||
public static final String CHANNEL_LATEST_LINK = "latest-link";
|
||||
|
||||
/**
|
||||
* Contains the enclosure link to the last feed entry.
|
||||
*/
|
||||
public static final String CHANNEL_LATEST_ENCLOSURE = "latest-enclosure";
|
||||
|
||||
/**
|
||||
* Description of the feed.
|
||||
*/
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.rometools.rome.io.SyndFeedInput;
|
||||
* sent to one of the channels and for the regular updates of the feed data.
|
||||
*
|
||||
* @author Svilen Valkanov - Initial contribution
|
||||
* @author Juergen Pabel - Added enclosure channel
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class FeedHandler extends BaseThingHandler {
|
||||
@@ -169,6 +170,13 @@ public class FeedHandler extends BaseThingHandler {
|
||||
state = new StringType(getValueSafely(latestEntry.getLink()));
|
||||
}
|
||||
break;
|
||||
case CHANNEL_LATEST_ENCLOSURE:
|
||||
if (latestEntry == null || latestEntry.getEnclosures().isEmpty()) {
|
||||
state = UnDefType.UNDEF;
|
||||
} else {
|
||||
state = new StringType(getValueSafely(latestEntry.getEnclosures().get(0).getUrl()));
|
||||
}
|
||||
break;
|
||||
case CHANNEL_LATEST_PUBLISHED_DATE:
|
||||
case CHANNEL_LAST_UPDATE:
|
||||
if (latestEntry == null || latestEntry.getPublishedDate() == null) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<channel id="latest-description" typeId="latest-description"/>
|
||||
<channel id="latest-date" typeId="latest-date"/>
|
||||
<channel id="latest-link" typeId="latest-link"/>
|
||||
<channel id="latest-enclosure" typeId="latest-enclosure"/>
|
||||
<channel id="author" typeId="author"/>
|
||||
<channel id="description" typeId="description"/>
|
||||
<channel id="title" typeId="title"/>
|
||||
@@ -71,6 +72,13 @@
|
||||
<state readOnly="true" pattern="%s"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="latest-enclosure">
|
||||
<item-type>String</item-type>
|
||||
<label>Latest Enclosure</label>
|
||||
<description>Contains the first (if any) enclosure link of the last feed entry.</description>
|
||||
<state readOnly="true" pattern="%s"/>
|
||||
</channel-type>
|
||||
|
||||
<channel-type id="author" advanced="true">
|
||||
<item-type>String</item-type>
|
||||
<label>Author</label>
|
||||
|
||||
Reference in New Issue
Block a user