Giter Club home page Giter Club logo

bigboxer23 / meural-control Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 1.0 301 KB

Push content to a Meural display from sources not supported by the official software. Supported sources include OpenAI TextCompletion (Dall-e 3), OpenAI ChatGPT (Dall-e 3), a Google Photos Album, James Webb Space Telescope, or an external URL.

License: Apache License 2.0

Java 98.96% Shell 1.04%
meural google-photos google-photos-api dall-e java openai openai-api google-calendar google-calendar-api google-calendar-integration chat-gpt chatgpt gpt-4 jwst dall-e-3

meural-control's Introduction

CodeQL

meural-control

This project provides ability to push content to a Meural display from content sources not supported by the official software. Supported sources include OpenAI TextCompletion -> Dall-e 3, OpenAI ChatGPT -> Dall-e 3, a Google Photos Album, James Webb Space Telescope, or an external URL. It provides a webserver and services with swagger documented endpoints that can be leveraged to control the Meural and push arbitrary content. The user/pw of the netgear account need to be provided, so we can fetch the Meural information and control it locally.

It leverages Meural's API which their web-interface and mobile app run on. Documentation can be found here.

There is also an http server that runs directly on the Meural device, which is used to post content directly to. Using preview functionality on the Meural is possible and works, however it seems to inconsistently keep content displayed, even after changing the preview time to be longer than between the scheduler's iteration period. Instead, by default we leverage a defined playlist to push content to and display on the Meural. We clean up items so there's only one item stored directly in the playlist and on the Meural at any time. This project currently uses /remote/postcard/, /remote/control_command/set_key/, /remote/control_command/resume, /remote/control_command/suspend & /remote/control_check/sleep commands

Content Sources

Each of the sources will iterate through its content and display a new item from the source by the period defined by scheduler-time value set in application.properties (other than passing an arbitrary URL to the web server's API endpoint, which displays once).

Google Photos

To set up google photos integration, navigate to here and follow instructions to create a credentials.json file. This file should be placed within the src/main/resources directory. Once the server starts up, there will be a URL printed to the console logs which needs to be navigated to in a browser. It will prompt you to log into your Google account and request the appropriate scopes for the integration. Once this successfully completes, a token will be stored on the server so log-in is not necessary again (unless the token is revoked manually).

Within the application.properties file, there is a required property, gPhotos-albumTitle, which defines the Google Photos album to push content from.

OpenAi (Dall-E 3)

This source allows using OpenAI's dall-e 3 text to image generator to create custom images to display on the frame from a text prompt provided by the application.properties file or by updating the prompt used via rest endpoint. The prompt is fed into either the GPT-3 text completion or ChatGPT-3's (or ChatGPT-4's) chat completion with each new image request, so it slowly morphs over time to something different. The prompts are potentially saved with the file names if a gPhotos album name is defined (openai-save-album). Note: using this endpoint does require OpenAI credits.

This endpoint also integrates with Google calendar to retrieve the US Holiday calendar. It will apply the holiday's name for a week prior to holiday to any AI generated prompts so some spicy holiday content will get generated.

James Webb Space Telescope

This source scrapes content from https://webbtelescope.org/ and when new content is posted, will display it on the Meural.

External URL

displayContentFromUrl endpoint allows the application to fetch the content from the provided URL and attempt to display it on the Meural. Currently supported file types are png, jpg, or gif

application.properties

An application.properties file is necessary to be placed into src/main/java/resources. An example file exists in the directory with the additional .example suffix. It should contain a few properties:

server.port:[port for this application to run on. Example:8081]
logbackserver=[Optional IP/port for a logback server to get events. If not defined, modify logback.xml to log to stdout or a file. Example: 192.168.0.7:5671
meural-account=[your netgear acct email]
meural-password=[your netgear acct password]
meural-playlist=[What playlist should be used to push content to? If the playlist does not exist, it will be created.] meural-orientation=[What is the orientation of your Meural? Example:vertical|horizontal] gPhotos-albumTitle=[Album Name Example: Art]
host=[hostname/IP where to publish to when mvn package is run]
scheduler-time=[cron expression for when to switch artwork. Example for running every two hours: 0 0 0/2 * * ?]
openai-key=[your openAI api key here]
openai-prompt=[A prompt to start generating artwork with Example:astronaut cats orbiting around a planet in the style of van gogh]
openai-save-album=[An album in google photos where images which are not sourced from gPhotos directly can be saved. Leave blank if no save is desired Example:empty or "Ai Art"]
jwst-save-album=[An album in google photos where fetched images can be saved. Leave blank if no save is desired Example:empty or "James Webb Space Telescope"]
transform-command=[Call an external command on an image prior to display. First parameter is the downloaded file, second parameter is where the new file is saved. Leave blank to do nothing. Example:convert %s -crop 960x1440+0+0 %s] transform-preview-commmand=[Call an external command on an image prior to preview display. First parameter is the downloaded file, second parameter is where the new file is saved. Leave blank to do nothing. Example:convert %s -crop 960x1440+0+0 %s]

Swagger

Swagger UI is available at http://127.0.0.1:8081/swagger-ui/index.html. It describes the webservice endpoints and allows usage directly in the browser.

Installation

  1. There are some GitHub package dependencies. GitHub requires maven authenticate as a valid user to fetch from their package repository.
    • Create ~/.m2/settings.xml if it does not exist
    • Create a GitHub personal access token if you do not have one (settings -> developer settings -> tokens classic)
    • In below example need to update username to your own GitHub username. Update password to include your GitHub access token created in the previous step
    • Example file:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository />
  <interactiveMode />
  <usePluginRegistry />
  <offline />
  <pluginGroups />
  <servers>
    <server>
      <id>github</id>
      <username>[my username]</username>
      <password>[my GH Access Token]</password>
    </server>
  </servers>
  <mirrors />
  <proxies />
</settings>
  1. Run install.sh
    • This is intended to be installed onto a raspberry pi or some other local server. install.sh will install it to a host of your choosing. The script needs to have the appropriate host variable set for where installation is desired.
  2. Google photos authentication
    • When the app initially launches, it will print a URL to the console which needs to be navigated to and proper authorizations given. The browser this URL is launched in needs to be on the same machine as the meural-control is installed on. If that isn't possible (for headless installations for instance), it is possible to run the OAuth flow on a non-headless server and authenticate, and transfer the generated tokens/StoredCredentials to the appropriate directory on the remote headless machine. install.sh contains a commented line that does exactly this.
  3. Running on start of server (assuming raspberry pi)
    • sudo systemctl restart meural.service
  4. Other
    • Java needs to be available and installed (java 17+)
    • On raspberry pi run sudo apt install default-jdk

meural-control's People

Contributors

bigboxer23 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

willjrowe

meural-control's Issues

401 Unauthorised error for Utils dependency

I am complete noob with all the terminology. I tried everything as per readme file.

On running install.sh, I get 401 unauthorised error for utils url https://maven.pkg.github.com/bigboxer23/_

I replaced it with the utils url I found in your profile but looks like the version its looking for is 2.0.15 and the new version is 2.0.16 or I might be reading that completely wrong.

I tried manually copying files under utils and now I am getting long list of java errors during test runs.

JWST display is only working every other time it's run

See the following exception every other time 'nextPicture' api is called.

Cannot add to playlist to device{"errors": "You cannot add an empty playlist to your Canvas"}
at com.bigboxer23.meural_control.MeuralComponent.addPlaylistToDevice(MeuralComponent.java:125)
at com.bigboxer23.meural_control.MeuralComponent.addItemToPlaylistAndDisplay(MeuralComponent.java:113)
at com.bigboxer23.meural_control.MeuralComponent.lambda$changePicture$4(MeuralComponent.java:306)
at com.bigboxer23.meural_control.MeuralComponent.executeAfterFetchCommand(MeuralComponent.java:264)
at com.bigboxer23.meural_control.MeuralComponent.fetchItem(MeuralComponent.java:275)
at com.bigboxer23.meural_control.MeuralComponent.changePicture(MeuralComponent.java:306)
at com.bigboxer23.meural_control.SchedulerComponent.lambda$doAction$0(SchedulerComponent.java:62)
at java.base/java.util.Optional.map(Optional.java:260)
at com.bigboxer23.meural_control.SchedulerComponent.doAction(SchedulerComponent.java:56)
at com.bigboxer23.meural_control.SchedulerComponent.nextItem(SchedulerComponent.java:98)
at com.bigboxer23.meural_control.MeuralController.handleResponse(MeuralController.java:53)
at com.bigboxer23.meural_control.MeuralController.nextPicture(MeuralController.java:187)

Assistance Setting Up

Hi first of all thank you so much for providing this awesome repo! I just purchased my first Meural product and am super excited to play around with stuff like this. I am a bit of a novice when it comes to hosts/networking/servers/ports/etc. lol so I was hoping you could help me configure my application.properties to run your service. I am hoping to run all of this on my personal laptop but would be willing to purchase a raspberry pi or something similar if necessary.

Currently this is what my application.properties looks like:

server.port:8081
logbackserver=192.168.0.7:5671
meural-api=https://api.meural.com/v0/
meural-account=<user>
meural-password=<pw>
meural-playlist=test
meural-orientation=vertical
host=192.168.0.6

I pretty much just put random IPs / ports in hopes it would work but I'm fairly certain there are some more settings / paths I need to configure. (particularly in the install.sh script, etc.)

Please let me know if there's any more info I can provide. Also I would be more than happy to contribute to the documentation adding any experiences / difficulties I had in order to help others in the future.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.