I am new in this but hopefully somone can help me. What I want to do is having a card that shows map from https://www.marinetraffic.com/ so I can track a certain ship. The card must update automatically. Is this something I can do?
Are you using HA in https?
If so, you must replace the js url by https://www.marinetraffic.com/js/embed.js in the html (cannot mix http and https on the same page)
I have been looking at the same thing. Based on nickrout’s previous example, this is working for me:
Inside HA on a web card
As a panel (along the side)
As a stand-alone file in a browser - good for configuring the parameters
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Embedded AIS</title>
</head>
<body>
<script type="text/javascript">
width='1000'; // the width of the embedded map in pixels or percentage
height='1000'; // the height of the embedded map in pixels or percentage
border='1'; // the width of the border around the map (zero means no border)
shownames='false'; // to display ship names on the map (true or false)
latitude='25.5'; // the latitude of the center of the map, in decimal degrees
longitude='-79.550'; // the longitude of the center of the map, in decimal degrees
zoom='5'; // the zoom level of the map (values between 2 and 17)
maptype='1'; // use 0 for Normal Map, 1 for Satellite
trackvessel='0'; // MMSI of a vessel (note: vessel will be displayed only if within range of the system) - overrides "zoom" option
fleet=''; // the registered email address of a user defined fleet (user's default fleet is used) - overrides "zoom" option
</script>
<script type="text/javascript" src="http://www.marinetraffic.com/js/embed.js"></script>
</body>
</html>
Question: What does it take to get Home Assistant to act on an edit to the html file? Much of my troubleshooting time was spent trying to get the javascript edits to be picked up by HA.
I write custon event logs to a text file and this was the best solution I found to allow the file to update on each page load. Substitute your URL as necessary.
<html>
<head>
<script>
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
</script>
</head>
<body>
<script>document.write(httpGet("/local/logs/event_log.txt?" + Date.now()));</script>
</body>
</html>
The date.now part makes each page load think that this is a different file so it forces a fresh relaod of the content. This may not work if your URL is also using parameters (the part after the ?) to pull specific information. Of course with a little creative programming you could make it work. Hope this helps.