[Solved] Accessing Device State Data for Experience Views


I am trying to make a custom widget on an experience view and need to access device state data from the Losant API. While this is possible to do with the losant-rest node module, I was wondering if it could be done without it on browser/client-side JavaScript?

Thank you in advance!


Are you trying to do it with client-side Javascript but without the rest module, or are you trying to not use client Javascript at all?

Each can be accomplished.



Thank you for your reply. I’m preferably trying to not use the rest module at all in order to have browser-compatible code.


Great! Thanks for your response.

There are two ways you could go about doing this.

1. Calling State with PageData

First is to go to the Experience Page’s attached workflow, which should have an Endpoint Trigger and an Endpoint Reply.

Within this workflow you can use a Data: Gauge Query or Data: Time Series node to get the current state or past state of a device.

You can then pass this data through the “Custom Page Data JSON Template” input in the Endpoint Reply node to your Experience Page, and then can use handlebars to call your data. Here I have called the status of my dishwasher, and can see it’s status listed on the page I am working with.


2. Device ID Route

Another way to do this is to create an Experience Endpoint with the device’s id in the route name. This can be done dynamically to allow for different device data by using {device_id} in the route name.

You can then go to this Experience Page’s workflow and again use either a Data: Gauge Query or Data: Time Series node to get the device’s state, and put this data path in the “Response Body Template” input of the Endpoint Reply node.

The device data will then be available at that website route, and can be called from the page with a script.

Hopefully this helps!


Sorry for the late response! thank you so much for your help! i’ll try it out :slight_smile:

1 Like