Writing to virtual device (temperature)

Hi,

I’m using node-red to get outside temperature from SignalK over node-red into the Cerbo. Unfortunately I don’t find a lot of documentation on virtual devices. And while they look like the have an input, I failed to write to it directly. Now I have a node that creates a virtual device and then I write updates over MQTT, like this:

I think it would be a lot easier, if I could just write directly to the device. I tried, without success, the same with GPS writing an object according to this doc dbus · victronenergy/venus Wiki · GitHub as msg.payload to the virtual device:

msg.payload = {
    Position: {
        Longitude: msg.payload.longitude,
        Latitude: msg.payload.latitude
    }
}
return msg;

Does anybody know if it’s possible to send message directly to a virtual device without going through MQTT?

1 Like

I do not know about importing from Signal K, but I write values from Node-RED nodes direct into virtual GPS, temperature and batteries. My GPS data is coming in from a USB GPS with averaging to reduce the erratic data.

On your GPS, split latitude and longitude separately and send them into a custom node for virtual GPS and choose latitude and longitude.

Currently I have no virtual temperature, just make sure that the message payload coming in is a number and it should work, check with debug.

1 Like

I solved it by the classical RTFM! My bad. node-red v3.1.15 and @victronenergy/node-red-contrib-victron v1.6.44 allow you to write directly to the virtual device.

The code payload needs to look like this.

msg.payload = { "/Position/Latitude": ..., "/Position/Longitude": ... }

The “properties” can all be found here for all devices: dbus · victronenergy/venus Wiki · GitHub
Brilliant!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.