This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signal K: Adding Keys / new sensor
#1
Hi folks!

I'm currently playing with Signal K the first time on a more serious level and I am starting to really enjoy it.

I also tried the API to read some values, also to change some values after authentication. 

As I have a serial protocol which is not supported by OpenPlotter, I need to run Node-RED to grab some UART data and create some jsons based on the information. In this case: My solar charger's information, current, power etc.

Long story short: I would like to add this data into Signal K and as I am able to modify keys using the API, I could do it. However, I asked myself if I can create own keys and a new type of data.
The API can't create new keys - is there any way to do this with Signal K directly?

Thanks!
Reply
#2
(2024-03-17, 01:32 PM)SirReal Wrote: Hi folks!

I'm currently playing with Signal K the first time on a more serious level and I am starting to really enjoy it.

I also tried the API to read some values, also to change some values after authentication. 

As I have a serial protocol which is not supported by OpenPlotter, I need to run Node-RED to grab some UART data and create some jsons based on the information. In this case: My solar charger's information, current, power etc.

Long story short: I would like to add this data into Signal K and as I am able to modify keys using the API, I could do it. However, I asked myself if I can create own keys and a new type of data.
The API can't create new keys - is there any way to do this with Signal K directly?

Thanks!

Node red will do that for you, send the value as  msg.payload  and the key as msg.topic  to a signalk-send-pathvalue node. You can try using an inject node which lets you set those.

Or send a signalk delta json with the new keys in it & signalk will create them. siggK does it all for you 

Copy & paste this into the data fiddler & click send to server then have a look in the data browser >>

[
  {
    "updates": [
      {
        "source": {
        },
        "values": [
          {
            "path": "testing.testing",
            "value": "Hello world"
          }
        ]
      }
    ],
    "context": "vessels.self"
  }
]
Reply
#3
okay, thanks again, PaddyB. My try with a simple Insomnia API call didn't let me add something but I tried a specific path, maybe I need to create a complete new one. Thanks!
Reply
#4
PS: I found the full and delta model explanation - okay, now I got it...
The node is much bigger than I thought before and a simple put on an address won't work, you need to put a delta action on the node. Cool that this is existing in Node-RED but I will first try this directly
Reply
#5
(2024-03-17, 06:51 PM)SirReal Wrote: PS: I found the full and delta model explanation - okay, now I got it...
The node is much bigger than I thought before and a simple put on an address won't work, you need to put a delta action on the node. Cool that this is existing in Node-RED but I will first try this directly

Heres another handy way to get at sigK deltas in a function node, set up lodash then it can read the values >

[Image: L1gYkIJ.png]

Code:
[
    {
        "id": "8c56f0aa3d0a6aaa",
        "type": "signalk-send-pathvalue",
        "z": "d5d630826742fbee",
        "name": "",
        "source": "",
        "meta": "",
        "x": 570,
        "y": 3200,
        "wires": []
    },
    {
        "id": "bde73b71071b24fe",
        "type": "inject",
        "z": "d5d630826742fbee",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "test.test",
        "payload": "hello everyone",
        "payloadType": "str",
        "x": 240,
        "y": 3200,
        "wires": [
            [
                "8c56f0aa3d0a6aaa",
                "d17dbb509637addf"
            ]
        ]
    },
    {
        "id": "d17dbb509637addf",
        "type": "delay",
        "z": "d5d630826742fbee",
        "name": "",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 240,
        "y": 3280,
        "wires": [
            [
                "858904937313d37a"
            ]
        ]
    },
    {
        "id": "858904937313d37a",
        "type": "function",
        "z": "d5d630826742fbee",
        "name": "function 12",
        "func": "let _ = global.get('lodash');\nlet app = global.get('app');\nlet test = app.getSelfPath('test.test');\nmsg.payload = test;\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 3280,
        "wires": [
            [
                "33954b51d46a38f7"
            ]
        ]
    },
    {
        "id": "33954b51d46a38f7",
        "type": "debug",
        "z": "d5d630826742fbee",
        "name": "debug 35",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 3280,
        "wires": []
    }
]

Ain't nuthin node red can't do  Big Grin
Reply
#6
cool. thanks. Good to know.

Just if someone else is reading this: What was confusing me is that HTTP rest calls (PUT) can only change node-paths which are made for that and will do an action afterwards.
If you just want to send a sensor's data in, you need a websocket connection to make delta calls. I was not aware of that...


Attached Files Image(s)
   
Reply
#7
(2024-03-17, 06:51 PM)SirReal Wrote: PS: I found the full and delta model explanation - okay, now I got it...
The node is much bigger than I thought before and a simple put on an address won't work, you need to put a delta action on the node. Cool that this is existing in Node-RED but I will first try this directly

Hi

can you give the URL where you found the full model explanation ?

thankx and regards
Reply
#8
(2024-03-18, 02:46 AM)gildas declercq Wrote:
(2024-03-17, 06:51 PM)SirReal Wrote: PS: I found the full and delta model explanation - okay, now I got it...
The node is much bigger than I thought before and a simple put on an address won't work, you need to put a delta action on the node. Cool that this is existing in Node-RED but I will first try this directly

Hi

can you give the URL where you found the full model explanation ?

thankx and regards

sorry, I did read it just now. Here the link:

https://signalk.org/specification/1.7.0/...model.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)