TileBoard icon indicating copy to clipboard operation
TileBoard copied to clipboard

RSS Feed

Open sibpph opened this issue 5 years ago • 2 comments

Can you help me add rss/news feed type or add xml parser to iframe?

Thank you,

sibpph avatar Nov 25 '19 11:11 sibpph

That would be amazing to have.

darox avatar Nov 29 '19 16:11 darox

Yes you can

You can use the TYPES.CUSTOM like this: The input boolean is a helpen in Home Assistant used for state and to keep track of last_changed. You can use is for creating an interval to refresh, otherwise it refreshed every time tileboard refreshes In my example I grab the RSS feed from a Dutch weather site.

                  {
                     position: [3, 0],
                     type: TYPES.CUSTOM,
                     id: 'input_boolean.loadrain',
                     title: '',
                     width: 4,
                     height: 3,
                     state: false,
                     customStyles: {'background-color': '#415473'},
                     customHtml: function(item, entity) {
                        var d = new Date(entity.last_changed);
                        d.setSeconds(d.getSeconds() + 60);
                        if (entity.state == 'on' && Date.now() > d) {
                           $http = angular.injector(["ng"]).get("$http");
                           $http.get("https://data.buienradar.nl/1.0/feed/xml/rssbuienradar").then(function(data) {
                              document.getElementById('rssText').innerText = new window.DOMParser()
                                 .parseFromString(data.data, "text/xml")
                                 .querySelectorAll("item")[0]
                                 .querySelector("description")
                                 .firstChild
                                 .textContent;
                           })
                        }
                        return '<div id="rssText" style="white-space:pre-wrap;text-align:left;padding:10px;overflow:scroll"></div>';
                     }
                  },

Romkabouter avatar Oct 09 '20 07:10 Romkabouter