FlightAware Discussions

PiAware web interface - How to add custom text?

Hello,
I would like to modify the default PiAware web interface to include a Temperature reading. I have a DS18B20 and short Python3 script which runs and outputs the current temperature to a text file. I would like setup the PiAware web service to read the temperature text file and then write the contents of the file to the default PiAware page; next to the Date and Time stamps.
image

Has anybody done this already or know of any how to guides I could look at?

I haven’t done this, but looking at it a very quick and dirty way would be to:

Open /usr/share/skyaware/html/index.html

Add a new div to buttonContainer so it looks like:

<div class="buttonContainer">
  <div class="dateTime" id="clock_div"></div>
  <div class="dateTime" id="temperature_div"></div>
  ... (there is other stuff inside this div)

Add in some inline Javascript just above the title tag:

<script type="text/javascript">
  setInterval(function() {
    $('#temperature_div').load('temperature.txt');
  }, 1000);
</script>

Have your script write to /usr/share/skyaware/html/temperature.txt with whatever you’d like to display. Change the 1000 in the JS to how often you want the temperature to refresh, 1000 is 1 second. Change the temperature.txt to whatever path you’d like to use relative to /usr/share/skyaware/html/

This will be wiped out and need to be redone if you upgrade PiAware or whatever. The above example looks like this with 94c written to the temperature.txt file.

1 Like

 

Above method by @hakubo should work OK

I have done similar (for embeding Gain Control), but my code was inserted above buttonContainer tag

 

1 Like

Thank you both for your help, @hakubo @abcd567 . I been reading loads of generic pages but your help is much more relevant. Have a good week.

2 Likes