• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

NOAA Tide Chart for Today, Tomorrow, and Next Day

Scheduled Pinned Locked Moved Development
7 Posts 3 Posters 393 Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    jyossarian
    last edited by Apr 13, 2024, 11:47 AM

    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();
    
    
    S 1 Reply Last reply Apr 13, 2024, 11:55 AM Reply Quote 0
    • S Away
      sdetweil @jyossarian
      last edited by Apr 13, 2024, 11:55 AM

      @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.

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      C 1 Reply Last reply Apr 13, 2024, 3:17 PM Reply Quote 0
      • C Offline
        cyberphox @sdetweil
        last edited by Apr 13, 2024, 3:17 PM

        where is this Tide module? don’t see it anywhere?

        Full time Dad, DJ and entertainer and lover of technology.

        S 1 Reply Last reply Apr 13, 2024, 3:30 PM Reply Quote 0
        • S Away
          sdetweil @cyberphox
          last edited by Apr 13, 2024, 3:30 PM

          @cyberphox
          https://github.com/crice009/MMM-NOAATides
          lookup user on github and then look thru their repos

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          C 1 Reply Last reply Apr 13, 2024, 3:41 PM Reply Quote 0
          • C Offline
            cyberphox @sdetweil
            last edited by cyberphox Apr 13, 2024, 3:42 PM Apr 13, 2024, 3:41 PM

            @sdetweil Thank you!

            edit - darn nothing for east coast of Canada!

            Full time Dad, DJ and entertainer and lover of technology.

            1 Reply Last reply Reply Quote 0
            • J Offline
              jyossarian
              last edited by Apr 13, 2024, 8:28 PM

              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?

              S 1 Reply Last reply Apr 13, 2024, 8:56 PM Reply Quote 0
              • S Away
                sdetweil @jyossarian
                last edited by Apr 13, 2024, 8:56 PM

                @jyossarian there are hundreds of modules that can be used. but none of it is simple.

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  7/7
                  Last post
                Enjoying MagicMirror? Please consider a donation!
                MagicMirror created by Michael Teeuw.
                Forum managed by Sam, technical setup by Karsten.
                This forum is using NodeBB as its core | Contributors
                Contact | Privacy Policy