Display Traffic Info

There are two ways I can go to work, a primary way that is most reliable and a secondary way that is less reliable but an option if it’s going to be much faster than the primary way. I want to set up a large (24+ inch) display in our mud room, and have Sharptools display traffic info on it in the morning only (no need to muck up the screen all the time). And I want Sharptools to only display traffic info (e.g., highlighted in red) IF I should take the secondary route instead of the primary route. So the display would show something like this highlighted somehow:

car/traffic icon Take Kildaire Farm Rd
10 minutes faster

Any chance Sharptools can do some/all of this? I already have a Google Traffic API key and can make the needed Google Traffic API calls on my smart home hub (Hubitat). It’s just a matter of whether Sharptools can be programmed to selectively display this info.

What would you want to happen when the traffic information isn’t displayed?

Keep in mind that tiles are automatically reflowed from left-to-right, top-to-bottom… so if the tile didn’t exist, it would cause the rest of the tiles to reflow.

One approach would be to use a Media Tile and externally determine which image to show.

For example, you could have the external system render the traffic time as an image and have it show the appropriate traffic times during the morning, then have it switch back to a photo of your family or favorite sports team or something else as a placeholder during the other times.

We’re also working on some updates around adding Variables to the Rule Engine, so I’ve noted the request. It sounds like this has several different components to it with the data, the dynamic hide/show, the dynamic color, etc. so I wouldn’t expect it to be all of this to be achievable with the initial release of Variables, but I’ve noted the use cases nonetheless.

Preferably, just whatever nice background image/wallpaper I’ve set up. That would be preferable over a “replacement” tile. Although, can a tile just be rendered to be blank and completely transparent?

I guess. Not sure how I would go about doing that. I can look into it perhaps. It looks like the only way to show traffic info right now is via a map, rather than simple text/number fields. I’m a minimalist, so the map is overkill for me.

Ok, thanks. I’ll keep my out eye for it. Any ballpark (non-guaranteed) time estimate on the initial release?

You can certainly display a text value. For example, the following post is using the Google Traffic API to do exactly that:

There were a lot of other requests included in the post though: displaying different routes based on which route is faster, changing the color based on the route, hiding it at different times, etc. :smiley:

That logic would need to run somewhere and render the appropriate output. In theory, it could even be done with a custom groovy ‘app’ on your Hubitat hub, but would require some programming.

For example, here’s a case where a user is using an external app to parse a result from an API and then render a relevant image:

Ah, ok cool. I’ll look into that. I’ve tinkered with some groovy programming so I am sure I could get it to work. Thanks for referral to the commute time map tile generator. I feel like I can get it to work the way I want to if there’s a way to selectively generate the map tile to be completely transparent.

Have you done any Node.js programming before? I’m stubbing together a proof of concept for you - just the fundamentals of dynamically rendering an SVG. You would need to fill in the API side of things. :smiley:

No, haven’t done that before. But I’ve got programming experience and am up for learning whatever I need.

Cool, thanks. I am hitting up the developer of that map tile generator as well. Because that actually seems like it could be a good starting point as well.

Here’s a proof of concept to get you going. I think it covers most of the basics you’re looking for:

  • Query Google Maps for traffic time of Route 1
    • Currently hard coded, but you can easily change this.
  • Query Google Maps for traffic time of Route 2
  • Display whichever route is fastest
  • If Route 2 is faster than Route 1, display it in RED
  • If it’s not morning time, don’t display
    • Instead, it redirects to a pretty mountain.
    • You could make it display nothing, but the tiles have a fundamental shadow on them, so even if you make it render nothing, you’ll still see the slight shadow outline of the media tile. Hence, the recommendation of just displaying an image of your choice.

Here’s the project on Glitch which makes it easy for you to ‘Remix’ the project and edit it to fit your needs.


Wow, that’s great. Thanks! I’ll check it out this weekend

So, could I set up two dashboards, one with the traffic indicator and another without? And then choose to display the dashboard with the traffic indicator if a Habitat presence sensor indicates I’m still at home, and show the dashboard without the traffic indicator if I’m not home?

Yes if you are using the Fully Kiosk browser to display the dashboard. See the post below. You can create a rule and use your presence as trigger, and then use loadURL command to change the dashboard if you have installed the Fully DTH.

1 Like

Can I run that on a raspberry pi? I want to have a large 24” touchscreen, and the only way I know of to have that is to use a raspberry pi - or are there better options if I also need fully kiosk browser?

So, how will this work dynamically with an always-on dashboard? How often will the dynamically rendered SVG be refreshed on the dashboard? Once a day? Every minute? Once a day wouldn’t be good because the traffic situation varies throughout the morning. Just not sure how often Sharptools pulls the image data from the URL.

However often you specify. :slight_smile:

1 Like