Read the statement by Michael Teeuw here.
NOAA Tide Chart for Today, Tomorrow, and Next Day
-
Extreme noob here so be gentle.
First, crice009 has created a module to pull NOAA tide data from a specific monitoring station and graph predicted vs actual data. I’m looking for something a little different. I’d like to see a simple chart consisting of the tide times and heights for three days pulled every night. Should I create a new module or fork off of crice009’s.
I am reading the MM module building documentation but a LOT is going over my head.
Reading some other posts, I got the idea to ask chatgpt to write the code I think I want. Tell me what you think.
const axios = require('axios'); const moment = require('moment'); // Function to fetch tide data for a specific date async function fetchTideData(date) { try { const response = await axios.get('https://api.tidesandcurrents.noaa.gov/api/prod/datagetter', { params: { begin_date: date.format('YYYYMMDD'), end_date: date.format('YYYYMMDD'), station: '8722670', // NOAA station ID for Port of West Palm Beach product: 'predictions', datum: 'MLLW', units: 'english', time_zone: 'lst_ldt', format: 'json', } }); return response.data.predictions; } catch (error) { console.error('Error fetching tide data:', error); return []; } } // Function to display tide data for a specific date function displayTideData(date, tideData) { console.log(`High and Low Tides for Port of West Palm Beach (Date: ${date.format('YYYY-MM-DD')})`); console.log('--------------------------------------------------'); console.log('| Time | Type | Height (feet) |'); console.log('--------------------------------------------------'); tideData.forEach(tide => { console.log(`| ${tide.t} | ${tide.type} | ${tide.v} |`); }); console.log('--------------------------------------------------'); } // Function to fetch and display tide data for today, tomorrow, and the following day async function fetchAndDisplayTideData() { const today = moment(); for (let i = 0; i < 3; i++) { const date = today.clone().add(i, 'days'); const tideData = await fetchTideData(date); displayTideData(date, tideData); } } // Main function to execute the program async function main() { await fetchAndDisplayTideData(); } // Run the main function main(); -
@jyossarian the chatgpt info is really useless as it’s a program and not in module form.
a module collects data (axios in the chatgpt stuff), and builds a html div with the desired content in the getDom() function and returns that to MagicMirror
sounds like you want an html table in the div. I don’t know what data the existing module collects.
-
where is this Tide module? don’t see it anywhere?
-
@cyberphox
https://github.com/crice009/MMM-NOAATides
lookup user on github and then look thru their repos -
@sdetweil Thank you!
edit - darn nothing for east coast of Canada!
-
So if chatgpt cannot write my code, I’m SOL?
Can you think of any existing modules that can be edited (like weather) to get the desired result?
-
@jyossarian there are hundreds of modules that can be used. but none of it is simple.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login