AerialViews icon indicating copy to clipboard operation
AerialViews copied to clipboard

API to receive text strings to display

Open FunFrog-BY opened this issue 8 months ago • 5 comments

It would be great if we could send some text for the app to show via API (HTTP/JSON). For example, I want to display current room temperature and some other data from Arduino / ESP8266 devices. It would be a great use of the app text display abilities.

FunFrog-BY avatar Apr 02 '25 23:04 FunFrog-BY

That might be possible.

The basic idea would be for Aerial Views to have a built-in webserver so it can accept a POST or GET request with a message. That would then be displayed on-screen with an overlay (TextView) like Clock, Now Playing, etc

Also, if you're not aware, there is an app called TvOverlay that is similar.

EDIT: Here is the GitHub page with a load of resources for the app

theothernt avatar Apr 03 '25 10:04 theothernt

The basic idea would be for Aerial Views to have a built-in webserver so it can accept a POST or GET request with a message. That would then be displayed on-screen with an overlay (TextView) like Clock, Now Playing, etc

Yes, exactly!

Also, if you're not aware, there is an app called TvOverlay that is similar.

Thanks, i wasn't aware. But it seems like it is impossible to set it up only to work when AerialViews is active.

FunFrog-BY avatar Apr 07 '25 12:04 FunFrog-BY

Ok, now the next step is to think about the API calls. I think 1) a call to show a message and 2) a call to clear the message.

eg. http://192.168.1.7/message?text=some%20text or http://192.168.1.7/clear

Are there any example APIs you can point to that do something similar ?

theothernt avatar Apr 10 '25 12:04 theothernt

We have 8 slots to show the text now. Basic set of GET parameters in the link would be:

  • Slot
  • Text
  • TTL (optional)
  • Clear

The API system will override current app settings. For example, if we have a clock in the upper left corner normally in the top position, we can send something like http://192.168.1.7/message?slot=ult&text=23%20degrees&ttl=20 which will replace the clock with this text for 20 seconds.

Clear (or TTL expiration) will remove the API input from that slot so it can return to its default state (empty or something that was set up in the app). Each new API call with TTL will renew the current one.

The problem now is customization. Now we have not slot-based typography settings, but content-based. We can set up font size and weight for the clock and not for the slot the clock is in. But for the API to be more useful we need either to have slot-based typography settings in the app, or just to support 2 more GET parameters, such as:

  • Size
  • Weight

This way we will be able to control the typography depending on the info we show.

Also we will need 2 settings in the app:

  • Enable/Disable switch for the feature.
  • Listening port.

FunFrog-BY avatar Apr 11 '25 12:04 FunFrog-BY

Most of that sounds fine. Technically speaking, although the screen has 8 slots - they are not filled with anything unless the user picks an overlay. So it's not possible to just target 'upper left slot', for example. Also, although overlays are TextViews currently, that might not be the case in future.

For the moment, I'd prefer the user apply "Message" overlays (simple TextViews) to part of the screen, then target those via the API - for example...

/message1?text=something&duration=20

There are currently only 2 "Message" overlays, I can increase this to 4.

I can also allow text formatting to be possible via the API call, text weight + size as you suggest.

Only the Now Playing overlay can collapse when not in use (ie. it takes up no space), I can make the Message overlays do the same.

The API would only work when the screensaver (or Test screensaver) is running. The API server will not be running in the background.

theothernt avatar Apr 11 '25 15:04 theothernt

I should have a beta for this feature next week!

theothernt avatar Jun 27 '25 12:06 theothernt

The public beta, v1.7.9 beta2, has the first version of this API to test.

Please look in Settings > Overlays > Message > Message API

The server only runs while a) the screensaver is running and b) there is at least one message overlay assigned

To confirm the server is running, you can send a GET request to <ip address>:8081/status

To update a message overlay, send a POST request to <ip address>:8081/message/[1...4] with a JSON object, for example...

{
    "text" : "A simple test message (2 seconds)",
    "duration" : 2 // seconds
    // "textSize": 0, // 15-18-75
    // "textWeight": 0 // 100-300-900
}

There is no animation when changing messages as there is still work to do on this feature, so let me know what you think!

theothernt avatar Jul 14 '25 14:07 theothernt

Great, thanks, i will test it next week for sure.

FunFrog-BY avatar Jul 16 '25 23:07 FunFrog-BY

As this feature still needs work, it will continue to be in the beta but it won't be in the v1.7.9 release itself - I'm hoping to have it out in a week or two.

theothernt avatar Jul 24 '25 14:07 theothernt

I Tested it and i love it! Thank you very much!

Now i have a current playing song from my Last.FM and current qBittorrent speeds displayed on my TV! https://quickshare.samsungcloud.com/sph2wMpwTszX

I have even more ideas how to use it, but it's all i had time for now. Seems like i'm staying on beta for the time being.

FunFrog-BY avatar Jul 25 '25 00:07 FunFrog-BY

How is the feature working for you so far, I think I saw a crash from your device? (the crash relates to the port already being used)

theothernt avatar Aug 07 '25 19:08 theothernt

It works fine, i love it! Thanks again! I noticed upon testing that request wont always coming through but i wrapped everything in try..catch anyway so it's not a problem at all:

async function postToAerialViews(msg) {
    const url = `http://${global.credentials.TV_IP}:8081/message/1`
    //logger.log(`Отправка сообщения на URL: ${url}`);

    try {
        if (!msg) msg = ""
        msg = msg.replace(new RegExp(`${msgDelimiter}https://[^${msgBigDelimiter}${msgDelimiter}]*`, 'ig'), ' ')
            .replace('┃', '   ')
            .replace('🎮', '✜')
            .replace('⏸️', '‖')
            .replace('🔁', '⟳')
            .replace('🎧', '♪')

        const response = await axios.post(url, {
            text : msg,
            duration : 300 // seconds
            // "textSize": 0, // 15-18-75
            // "textWeight": 0 // 100-300-900
        }, { timeout: 2000 })
    } catch (error) {
        //logger.error('❌ Произошла ошибка при отправке сообщения AerialViews.');
    }
}

The script is working 24/7 since then, no problems at all. I just upgraded my telegram rich presence script to mirror everything from my dynamically updated bio to my TV. I haven't tried textSize & textWeight tho, sorry.

AerialViews sometimes crashes, yes. It isn't related to API stuff, it was always a thing. At first i thought that it's because it didn't like some filenames, but it just skipped some files until i renamed them. Then i thought that it just doesn't like some files... But i have an impression (not 100% sure) that it crashes just randomly somewhere mid-file. It is pretty rare anyway and after 5 mins idling TV starting it again automatically.

FunFrog-BY avatar Aug 09 '25 03:08 FunFrog-BY

Got the new version (1.7.9) via beta channel somehow. The feature is gone. Got a mini-heart atrack on the background of the SSD issues on latest Windows 11 update. Thiught my PC is dead, then tried to debug my sender app. Turned out AerialViews just got updated. Can you bring it back please?

FunFrog-BY avatar Sep 01 '25 05:09 FunFrog-BY

When v1.7.9 was released, I assumed that beta users would stay on v1.7.8 beta10 - but this is not the case.

It looks like a new stable release supersedes the beta.

The latest beta has been submitted, v1.8.0 beta1, with all those features enabled. It should be available in the next day or two.

theothernt avatar Sep 01 '25 17:09 theothernt

That should be working again, let me know if you find any issues!

theothernt avatar Sep 03 '25 14:09 theothernt