Notifications
Clear all

10/18/2023 Map Stopped Working?
Visit this post for the fix

livesectional alongside Node-Red?

7 Posts
2 Users
0 Reactions
1,835 Views
(@cegan09)
Active Member
Joined: 3 years ago
Posts: 12
Topic starter  

I want to run node-red alongside livesectional on the Pi, but it appears that doing so may break livesectional?

I have a livesectional install that has been working, then this morning I ran the install for node-red and I can no longer load the web interface for livesectional. The script is still running, because the map lights up and updates, but I can't access the webUI at all, just returns connection refused errors. 

 

What diagnostic info can I give to figure out what broke?

Also, is it possible to pull config files from somewhere if I have to end up just wiping the sd card and starting over?


   
Quote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 559
 

Hi, it may not be node-red (which I'm unfamiliar with, so tell us what it does please). There is an issue with a server being used as part of the update check routine that I'm trying to figure out. In the meantime there is a fairly quick work around that I posted yesterday. Just follow this link.

https://www.livesectional.com/community/raspberry-pi-questions/rpi-refuses-to-connect/#post-885

At some point I hope to figure out the root cause and fix it. But for now this will get things going again.

Once you have the web interface up and running again, you can download the config, airports and hmdata files from the 'Map Utilities menu so it makes updating the image much quicker and easier. - Mark


   
ReplyQuote
(@cegan09)
Active Member
Joined: 3 years ago
Posts: 12
Topic starter  

I actually just saw that post, looks like that's really the issue and I didn't look around enough first. Used the fix and now the webUI runs again, excellent. Sorry for the duplicate post, I assumed I'd broken something. 

 

Node-red is a visual coding environment that's used a lot for IoT and tying a ton of different services together. https://nodered.org/
I use it a ton for doing home made smart home routines and other projects. My weather lamp project is heavily built around it, and all the weather condition polling/parsing/logic is done in node-red. You could technically build the core functionality of livesectional in there as well, though I bet it would be a little less elegant than the current implementation. I'm really bad with code, just not my skillset, but the visual nature of node-red works for me. 

I mentioned in my project build thread that the map I'm building is going to a meteorologist friend, so I'm using node-red to build an environment that lets him pull and display other kinds of weather data if he prefers it over the standard metar color codes, but will let him flip easily back and forth between them. 


   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 559
 

That sounds like a great idea. Can't wait to see it in action. Thanks for the explanation of Node Red, I'll have to look into it. - Mark


   
ReplyQuote
(@cegan09)
Active Member
Joined: 3 years ago
Posts: 12
Topic starter  

I'll share my node-red setup when I have it all defined and built out, but here's a quick example of 1 possible mode. Pulls the latest observation data from each airport, extracts the current temp, maps that to a color, and plots the color giving you a literal heat map. Blue is ones that had some error pulling data, just haven't added the error handling in yet. 

I plan on doing the same thing for wind speeds and a few other data points, and then I assume my friend will build in the data that he's most interested in. 

Absolutely no reason you couldn't do this all within the live sectional software itself, temps are reported in the metar message. It's just easier for me to build things like this in node-red because normal code is not my strong point. 
If you're at all curious, the color mapping function I use is:
hue = -(0.0000000851493794154907*(Math.pow(TempF,5)))+(0.0000136269369035499*(Math.pow(TempF,4)))-(0.00000489267815373005*(Math.pow(TempF,3)))-(0.0571454349276795*(Math.pow(TempF,2)))-(1.76044127906889*(TempF))+264.176768774735

That's specifically formatted for javascript (which is what node red is based on), hence the odd exponent format. But you're just running a temp in °F through a polynomial formula to get a hue. You can then pass that hue through any number of conversions to get other color formats like RGB. 

 

20210830 161125

It's really hard to cleanly photograph this many LEDs head on.....

 

I don't suppose there is an easy way to tie in calls to start and stop the livesectional map from outside the web interface? Would be cool to be able to build a dashboard into node-red that would automatically stop the livesectional map then flip on the modes I'm writing, and vice versa. No worries if not, just asking. 

This post was modified 3 years ago by cegan09

   
ReplyQuote
Mark Harris
(@markyharris)
Member Admin Registered
Joined: 5 years ago
Posts: 559
 

Hmm, I'm not sure about that. I've only played with calls through the web interface. Although a bit kludgy, maybe you could use the web interface to turn off the map, then the Node Red interface to turn on your data? I use the web interface on my phone all the time, so its pretty easy to get to that menu item.

Another idea: Could you program a 'os' quit command in your Node Red dashboard? Here is the Flask Route used to turn off everything on the map;

# Route to turn off the map and displays
@app.route("/shutdown1", methods=["GET", "POST"])
    def shutdown1():
    url = request.referrer
    if url is None:
        url = 'http://' + ipadd + ':5000/index' #Use index if called from URL and not page.

    temp = url.split('/')
    logger.info("Shutoff Map from " + url)
    os.system("ps -ef | grep '/NeoSectional/metar-display-v4.py' | awk '{print $2}' | xargs sudo kill")
    os.system("ps -ef | grep '/NeoSectional/metar-v4.py' | awk '{print $2}' | xargs sudo kill")
    os.system("ps -ef | grep '/NeoSectional/check-display.py' | awk '{print $2}' | xargs sudo kill")
    os.system('sudo python3 /NeoSectional/shutoff.py &')
    flash("Map Turned Off ")
    time.sleep(1)
    return redirect(temp[3]) # temp[3] holds name of page that called this route.

The 4 'os.system' calls are what you would need to send the RPi. The first three kill the script processes running, then the forth one runs a script that turns off all the LED's and OLED's if used. So if Node Red would allow you to send os commands then this should work for you. Just a thought. - Mark

 


   
ReplyQuote
(@cegan09)
Active Member
Joined: 3 years ago
Posts: 12
Topic starter  

Oh for sure I can just flip the map on and off from the web interface, that would work just fine. I was just curious if there was a way to integrate the two, so on the node-red UI if you pressed the toggle to start temperature display it could first turn off the livesectional map, then kick off the temperature mode. Then you could turn off temperature mode and auto start the livesectional scripts again. 

I'll see if the OS calls are possible, maybe that will let it work. If no, no problem, using the two web interfaces is fine. 


   
ReplyQuote
Share: