Map marker to change color depending on connection status

With the new “connectionStatus” information for devices available, I’m trying to display this information in the PopUP bubble for each mapped device first , but would like to be able to changed the color of the marker.

I can easily display deviceId as " {{ deviceId}}" but can I somehow display “connectionStatus” similar to how I would display a tag using {{deviceTags.[key]}} ?

@Lars_Andersson our recent platform update does allow for returning a list of devices based on connection status - including within the editors dashboard blocks that accept advanced queries, such as the GPS History Block. I assume that’s the block you’re referring to in your question.

However, those query changes did not lead to any changes to what is actually returned when fetching data for your dashboard. The same context is available per point - and thus per popup - as was before.

That said, I will make a feature request to allow dashboard builders to opt in to a fuller device object to be returned. I expect that the feature would only return the device’s current connection status, not the connection status at each data point represented on the block.

Thanks for the suggestion, and I’ll keep you posted if we implement this.

Great.

so as it is now I would only be able to display devices that are either connected or disconnected, not mix these on the same map ?

You absolutely could mix the two; it just depends on how you build your device query within the block configuration. When returning data to use within the block, we do not take into account the connection status of the device - only whether a device matching the provided query has any state data to report within the block’s displayed timeframe.

@Lars_Andersson I may be able to walk you through a work around. Can you give me more information about your device and use case?

It applies to multiple types of devices, but they are in the same Losant application.
During the week or day they may go online/offline depending on the machines they operate on.
I just though it would be nice to show a map showing location and online status based on color codes.

Do the devices stay relatively stationary or are they moving around? Do you currently have the location of the device set using a tag or an attribute?

Stationary.
I have the location defined in a tag.

Great!

If you create a boolean attribute you can set 1=connected 0=disconnected. Then using a Device: Disconnect Trigger Node you can trigger a workflow that updates the attribute to 0 when disconnected.

To return the attribute to connected make sure you have the value set to 1 in all of your other Device: State Nodes.

Once you have this attribute set up you can then use the additional attribute feature of the GPS History block.

Select the advanced Pin Style option and you can then use handlebars to reference your attribute.

For example, if your attribute was connectionStatus and you wanted disconnected to be red and connected to be green.

{{#eq data.connectionStatus false}}
{{colorMarker ‘#FF261B’}}
{{else}}
{{colorMarker ‘#8DB319’}}
{{/eq}}

Let me know if this helps!