Does anyone have custom action Javascript code to navigate to new dashboard state on clicking different tooltips (map) of various devices of same devicetype which leads to different dashboard states.
IN MY CASE: I have three thermostats and I need to handle the actions on these three thermostates should open different dashboard states, however the device.type is same for all devices.(Thermostat)
I copied the code from Dashboard guide video part- 2 and just changed the variable "device.type to device.name" but it doesn't work. There should be another way of doing it with If conditions (Variable or Keyword that indicates specific device name).
I have also tried with 'entityName', 'device.entityName','device.Name', 'entityID', device.entityID etc. but nothing worked so far.
Custom action code:
var $injector = widgetContext.$scope.$injector;
$injector.get('deviceService').getDevice (entityID.id).then(function(device) {
if (device.name == 'thermostat1') {
openDashboardState ('Thermostat1');
} else if (device.name == 'thermostat2') {
openDashboardState('Thermostat2');
} else if (device.name == 'thermostat3') {
openDashboardState('Thermostat3');
}
});
function openDashboardState(stateId) {
var params = {
entityId: entityId,
entityName: entityName
};
Widgetcontext.statecontroller.openState(stateId, params, false);
}
I am a beginner in Javascript & Front-end development. Could any JS developer or expert in Thingsboard help me out? It would be great.
Thank you in advance.
Best Regards,
Thangz