Custom Component: SageTV

I have (poorly) written components for SageTV . There is a media_player as well as a sensor which is compatible with “Lovelace: Upcoming Media Card”. It has been stable for a few days, so probably good enough to share with people. The media_player works well (play/pause/commercial skip) but I cannot get the media_seek function to work. Also, the poster blinks every once in a while. Not sure how often I will update it, but perhaps a better coder can make it better
SageTV Homeassistant

So at some point this stopped working with upcoming media card, not sure why… any ideas? Below is the contents of the sensor.sagetv entity data attribute. It stopped working around the beginning of the year when that security patch for HA was released.

[{"titledefault": "$title", "icon": "none", "line1default": "$episode",
  "line2default": "$release", "line3default": "", "line4default": ""},
  {"number": "S3E7", "flag": "false", "airdate": "2021-06-09T18:00:00.000Z",
  "release": "Recorded: $day, $time", "fanart":
  "https://myserver.net/local/posters/Monk_FA", "rating": 7.4,
  "runtime": 30, "episode": "Mr. Monk and the Employee of the Month", "title":
  "Monk", "poster": "https://myserver.net/local/posters/Monk"},
  {"number": "S3E8", "flag": "false", "airdate": "2021-06-09T19:00:00.000Z",
  "release": "Recorded: $day, $time", "fanart":
  "https://myserver.net/local/posters/Monk_FA", "rating": 7.4,
  "runtime": 30, "episode": "Mr. Monk and the Game Show", "title": "Monk",
  "poster": "https://myserver.net/local/posters/Monk"}, {"number":
  "S0E0", "flag": "false", "airdate": "2021-06-09T21:30:00.000Z", "release":
  "Upcomming: $day, $time", "fanart":
  "https://myserver.net/local/posters/Us_FA", "rating": 7.4, "runtime":
  30, "episode": "Us", "title": "Us", "poster":
  "https://myserver.net/local/posters/Us"}, {"number": "S1E2", "flag":
  "false", "airdate": "2021-06-10T00:00:00.000Z", "release": "Upcomming: $day,
  $time", "fanart": "https://hass.flyingwolves.net/local/posters/Kung Fu_FA",
  "rating": 7.4, "runtime": 30, "episode": "Silence", "title": "Kung Fu",
  "poster": "myserver.net/local/posters/Kung Fu"}]

I am not sure, because I have not updated the upcoming media card, just to be sure this doesn’t happen to me. Looks like the upcoming media card has not been updated since November 2020.

To get it to work with the upcoming media card, you may need to edit the card code (because my python skills stink). Try this:
edit /config/www/community/upcomming-media-card/upcoming-media-card.js
find the lines that look like this:

const title_text = this.config.title_text || json[0]["title_default"];
const line1_text = this.config.line1_text || json[0]["line1_default"];
const line2_text = this.config.line2_text || json[0]["line2_default"];
const line3_text = this.config.line3_text || json[0]["line3_default"];
const line4_text = this.config.line4_text || json[0]["line4_default"];

and remove the _ between title_default, line1_default, etc.

here is the tricky step, you now need to use 7zip or something to gzip the file and name it upcoming-media-card.js.gz

If this doesn’t work, I can try to look into it more. the issue is the SageTV component is putting out line1default and his component expects an underscore.

I updated a new sensor.py to the repository. It should set the tiltle_default, etc keys correctly. Replace the custom_components/sagetv/sensor.py with the new one, and you can ignore the previous post.

wow that was fast! I’ll try it out, thanks!