【问题标题】:Show thingsboard device attribute latest value on customized control widget dashboard on thingsboard在 thingsboard 上的自定义控件小部件仪表板上显示 thingsboard 设备属性最新值
【发布时间】:2017-12-22 09:22:48
【问题描述】:

我正在使用 thingsboard V1.3.1。现在我正在开发 thingsboard 上的自定义控件小部件。我收到了 thingsboard 设备属性中的值。我想要通过传递 1 和 0 值来动态打开和关闭按钮。但我的问题是如何在 thingsboard 仪表板上自定义创建的开/关开关控件小部件上显示这个最新值。

任何帮助将不胜感激。

提前致谢,

维斯瓦

【问题讨论】:

    标签: thingsboard


    【解决方案1】:

    您可以先在此处配置您想要传递给小部件的参数!

    1. attributeService = $scope.$injector.get('attributeService');self.onIni 函数中,这将获取您刚刚在小部件数据源上设置的属性。

    2. 在此之后,您必须在小部件中恢复此信息。我建议您在 self.onDataUpdated 函数中执行此操作(thingsboard 使用 AngularJS),以便按钮将更新该值。

    self.onDataUpdated = function () {
            for (let i=0;i<subscription.data.length;i++) {
                let attributeValue = subscription.data[i].data[0][1];
                let dataKey = subscription.data[i].dataKey.name;
                if (dataKey === 'active') {
                    $scope.activeVal = (attributeValue === 'true');
                }
            }
        };
    

    这里不断地遍历每个属性,检查名称是否与“活动”匹配,如果是,则 $scope 属性 activeVal = 您传递给小部件的活动值。

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-11
      • 1970-01-01
      • 2022-06-16
      • 2019-03-22
      • 2019-07-07
      • 1970-01-01
      相关资源
      最近更新 更多