Commit bc2534ed5259906ccb93d37b7143a4b5195e8eab
Committed by
Andrew Shvayka
1 parent
edcad249
Added deviceName and deviceType to metadata on RPC call (#1596)
* Create Alarm Node add originator and status when using message data * Added deviceName and deviceType to metadata on RPC call
Showing
1 changed file
with
11 additions
and
0 deletions
... | ... | @@ -28,6 +28,7 @@ import org.thingsboard.rule.engine.api.RpcError; |
28 | 28 | import org.thingsboard.rule.engine.api.msg.ToDeviceActorNotificationMsg; |
29 | 29 | import org.thingsboard.server.actors.service.ActorService; |
30 | 30 | import org.thingsboard.server.common.data.DataConstants; |
31 | +import org.thingsboard.server.common.data.Device; | |
31 | 32 | import org.thingsboard.server.common.data.id.DeviceId; |
32 | 33 | import org.thingsboard.server.common.data.id.TenantId; |
33 | 34 | import org.thingsboard.server.common.msg.TbMsg; |
... | ... | @@ -38,6 +39,7 @@ import org.thingsboard.server.common.msg.cluster.ServerAddress; |
38 | 39 | import org.thingsboard.server.common.msg.core.ToServerRpcResponseMsg; |
39 | 40 | import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest; |
40 | 41 | import org.thingsboard.server.common.msg.system.ServiceToRuleEngineMsg; |
42 | +import org.thingsboard.server.dao.device.DeviceService; | |
41 | 43 | import org.thingsboard.server.gen.cluster.ClusterAPIProtos; |
42 | 44 | import org.thingsboard.server.service.cluster.routing.ClusterRoutingService; |
43 | 45 | import org.thingsboard.server.service.cluster.rpc.ClusterRpcService; |
... | ... | @@ -68,6 +70,9 @@ public class DefaultDeviceRpcService implements DeviceRpcService { |
68 | 70 | private ClusterRpcService rpcService; |
69 | 71 | |
70 | 72 | @Autowired |
73 | + private DeviceService deviceService; | |
74 | + | |
75 | + @Autowired | |
71 | 76 | @Lazy |
72 | 77 | private ActorService actorService; |
73 | 78 | |
... | ... | @@ -171,6 +176,12 @@ public class DefaultDeviceRpcService implements DeviceRpcService { |
171 | 176 | metaData.putValue("expirationTime", Long.toString(msg.getExpirationTime())); |
172 | 177 | metaData.putValue("oneway", Boolean.toString(msg.isOneway())); |
173 | 178 | |
179 | + Device device = deviceService.findDeviceById(msg.getTenantId(), msg.getDeviceId()); | |
180 | + if (device != null) { | |
181 | + metaData.putValue("deviceName", device.getName()); | |
182 | + metaData.putValue("deviceType", device.getType()); | |
183 | + } | |
184 | + | |
174 | 185 | entityNode.put("method", msg.getBody().getMethod()); |
175 | 186 | entityNode.put("params", msg.getBody().getParams()); |
176 | 187 | ... | ... |