Skip to content

Commit

Permalink
fix display error and sleep timer enable/disable
Browse files Browse the repository at this point in the history
  • Loading branch information
petersem committed Feb 2, 2024
1 parent 3826eb3 commit b9e4a94
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
3 changes: 0 additions & 3 deletions classes/cards/MediaCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ class MediaCard {
<div class="hidden" id="poster` + this.ID + `AR">`+this.posterAR+`</div>` +
this.triviaRender +
`</div>
<div class="hidden" id="link` + this.ID + `AR"></div>` +
this.linkRender +
`</div>
<div class="bottomBanner mx-auto transparent` +
` ` + hiddenFooter +
Expand Down
34 changes: 34 additions & 0 deletions classes/custom/awtrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const mediaCard = require("../cards/MediaCard");
const cType = require("../cards/CardType");
const util = require('util');
const axios = require("axios");
const { CardTypeEnum } = require("../cards/CardType");
var playing = null;

/**
* @desc Used to get a list of custom pictures
*/
class Awtrix {
constructor() { }

/**
* @desc Custom link slide array
*/
async post(ip,payload) {

await axios.post(
ip + "/api/custom?name=posterr", null
)

await axios.post(
ip + "/api/custom?name=posterr", payload
)

return 0;
}



}

module.exports = Awtrix;
49 changes: 49 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const pjson = require("./package.json");
const MAX_OD_SLIDES = 150; // this is with themes. Will be double this if tv and movie themes are off
const triv = require("./classes/custom/trivia");
const links = require("./classes/custom/links");
const awtrix = require("./classes/custom/awtrix");

// just in case someone puts in a / for the basepath value
if (process.env.BASEPATH == "/") process.env.BASEPATH = "";
Expand Down Expand Up @@ -112,6 +113,7 @@ let tmpSleepStart;
let tmpSleepEnd;
let recentlyAddedDays;
let contentRatings;
let oldAwtrixJson = "";

// create working folders if they do not exist
// needed for package binaries
Expand Down Expand Up @@ -482,6 +484,44 @@ async function loadNowScreening() {
loadedSettings.filterUsers,
loadedSettings.hideUser
);

// Send to Awtrix, if enabled
var awt = new awtrix();
var awtrixJson = [{
'text': "AlienS (1979)",
'pushIcon': 0,
'icon': "1944",
'color': [255,0,0],
'duration': 10,
'textCase': 2,
'scrollSpeed': 50,
'progress': 15,
'progressC': [255,0,0]
},
{
'text': "Buck Rojers (1980)",
'pushIcon': 0,
'icon': "1944",
'color': [255,255,0],
'duration': 10,
'textCase': 2,
'scrollSpeed': 50,
'progress': 60,
'progressC': [255,255,0]
}]

//console.log(JSON.stringify(oldAwtrixJson) !== JSON.stringify(awtrixJson));

if(JSON.stringify(oldAwtrixJson) !== JSON.stringify(awtrixJson)){
await awt.post("http://192.168.1.28",awtrixJson);
oldAwtrixJson = awtrixJson;
//console.log('updated awtrix');
}
else{
//console.log('skipped awtrix update');
}


// restore defaults if plex now available after an error
if (isPlexUnavailable) {
console.log("✅ Plex connection restored - defualt poll timers restored");
Expand Down Expand Up @@ -782,6 +822,15 @@ async function checkEnabled() {
// check sleep mode
// let startTime = await util.emptyIfNull(loadedSettings.sleepStart);
// let endTime = await util.emptyIfNull(loadedSettings.sleepEnd);
try {
if(loadedSettings.isSleepEnabled == "true")
isSleepEnabled = true;
}
catch (ex) {
isSleepEnabled = false;
}


try {
sleepStart = new Date("2100-01-01T" + loadedSettings.sleepStart);
isSleepEnabled = true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posterr",
"version": "1.16.10",
"version": "1.16.11",
"description": "A digital display for your media",
"main": "index.js",
"bin": "index.js",
Expand Down

0 comments on commit b9e4a94

Please sign in to comment.