send own data to signal-k

571 views
Skip to first unread message

Tommaso Speroni

unread,
May 4, 2022, 1:36:32 PM5/4/22
to Signal K
Hello everyone! 
I'm quite new here and I'm trying to send my own data to signal-k server.
For example when i receive data from a sensor (temperature or humidity) I'm able to send it using the data fiddler:
ex:

{
  "context": "vessels.urn:mrn:signalk:uuid:f615af09-56c1-4325-9390-4b22641fd06b",
  "updates": [
    {
      "timestamp": "2022-01-07T07:18:44Z",
      "values": [
        {
          "path": "environment.humidity",
          "value": 70
        }
      ]
    }
  ]
}

I see the data in the stream: 

Screenshot 2022-05-04 at 19.20.29.png


Now from a Python script I would like to do the same but reading the documentation is not clear to me how to send Delta via HTTP.

When I try to send via. HTTP with a PUT: 
this is the response
Screenshot 2022-05-04 at 19.35.37.png
Thank you very much!
Tommaso


Teppo Kurki

unread,
May 4, 2022, 1:42:42 PM5/4/22
to sig...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Signal K" group.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/signalk/306d3ef8-1575-445c-91eb-c49447fe5a06n%40googlegroups.com.

Tommaso Speroni

unread,
May 8, 2022, 8:56:16 AM5/8/22
to Signal K
Thank you very much for your answer. 
But is not clear to me why doing a PUT


with 
{
"value": "auto"
}

I receive a 405:
{
"state": "COMPLETED",
"requestId": "622a7e3b-e263-4581-a552-3b55bf1fb80a",
"statusCode": 405,
"message": "PUT not supported for steering.autopilot.state",
"href": "/signalk/v1/requests/622a7e3b-e263-4581-a552-3b55bf1fb80a",
"user": "1234-45653-3434533"
}

Many thanks

Jean Vasic

unread,
May 24, 2022, 2:39:26 PM5/24/22
to Signal K
Here is a Python3 example:

import asyncio
from websockets import connect

async def hello(uri):
    async with connect(uri) as websocket:
        message = await websocket.recv()
        print(message)

        login_msg ='{"requestId": "1234-45653-343454","login": {"username": "azerty","password": "uiop"}}'
        print(login_msg)
        await websocket.send(login_msg)
        print("login sent")
        message = await websocket.recv()
        print(message)

        beacon_msg = '{"context": "atons.urn:mrn:imo:mmsi:123456789","updates": [{"values": [{"path": "navigation.position.longitude","value": 14.99},{"path": "navigation.position.latitude","value": 31.99},{"path": "name","value": "BeaconPy"},{"path": "virtual","value": "true"},{"path": "atonType.name","value": "BLE Beacon Py"}]}]}'

        await websocket.send(beacon_msg)
        print("beacon sent:",beacon_msg)
        message = await websocket.recv()
        print(message)

asyncio.run(hello("ws://belpugapi:3000/signalk/v1/stream?subscribe=none"))
Reply all
Reply to author
Forward
0 new messages