sibbl / hass-lovelace-kindle-screensaver

This tool generates a png from a Home Assistant Lovelace view, which can be displayed on a Kindle device which has the Online Screensaver plugin installed.
MIT License
311 stars 71 forks source link

Slideshow for non-jailbroken version #42

Closed LorenzoRogai closed 1 year ago

LorenzoRogai commented 1 year ago

Hi,

Is it possible to add an endpoint with some little Javascript code that cycles through the various screenshots at a regular interval?

In this way the URL can be opened inside the default Kindle browser and it should work fine

Thank you

sibbl commented 1 year ago

Hi,

thanks for the feedback. I see two questions here:

  1. without jailbreak, using the default Kindle browser should result in the device turning off after a specific time. Even if this could be solved, I then think opening the Home Assistant dashboard directly might work better. So there would be no need for this rendering tool.

  2. cycling throught various lovelace panels/components is something which should be doable in the Home Assistant dashboard and might be out of scope for this plugin. You can modify some input_number helper value every minute and then use a dashboard component which only shows a specific component if this input_number field is 1, 2 or 3.

In the end, we just render the Home Assistand dashboard. So whatever is configured there, will also be usable by this tool :)

LorenzoRogai commented 1 year ago

If you input ~ds inside the Kindle search bar you can disable the sleep mode. Opening the dashboard directly doesn't work because of HA advanced Javascript that Kindle can't render

I was meaning something like

dockerip:5000/slideshow

That contains this HTML

<img src="http://mini-pc.home.internal:5000/">

<script>
function randomIntFromInterval(min, max) { // min and max included 
  return Math.floor(Math.random() * (max - min + 1) + min)
}

setInterval(function() {
  document.getElementsByTagName('img')[0].src = 'http://mini-pc.home.internal:5000/' + randomIntFromInterval(1, 5);
}, 60000);
</script>

I'm going to host this outside the Docker container but i thought it would be helpful to have this all-in-one