Guidance through Mozilla-IOT by building webthing detection addon for 3rd-Party systems?

I fear that it’s not wanted to ask such questions here, that’s why I’m asking first.
Can I get guidance for a 3rd Party Homeautomationsystem building a Webthings detection?
I think of a guidance in architecture questions and understanding how it works, not code itself.

Hi @Novski,

Your question is very welcome. We want to encourage multiple implementations of Web of Things specifications. What do you need to know?

In order to build a client which is compatible with the same web things used by the WebThings Gateway, you would need to implement the Web Thing API (as an HTTP & WebSocket-based client).

Ben

Thanks for the acceptance. I’m not a very experienced developer but have an aged by 2010 knowledge about HTTP and its principles. Therefore, im not familiar with websockets yet.
The Web Thing API starts where websockets connection establishes and my first question is more about how to listen to the announcing of a Web Thing on the network.

In detail i have a node-red websocket node that can be configured to listen to a websocket. I can see the json of my Webthing in a Browser when in connect to http://192.168.0.29:8888/, how wold this translate to the websocket of a Webthing? eg. ws://192.168.178.29:8888/ seams not to receive any temperature values (what my Webthing sends each minute or so.).
Are you able to provide me some background on that?

You can find the proper WebSocket URL in the top-level thing description, as shown here: https://iot.mozilla.org/wot/#links-member

true! Thank you.

Let me ask a follow up question. I was able to create a connection to ws://192.168.0.29:8888/0 that responds with {"messageType": "propertyStatus", "data": {"level": " 31.88"}}.
As I am using a multiple Thing it would be nice to get the name of the Device with url: /0.
The Gateway shows that correctly. How does the Gateway read the name of the device that is saved in the Title?

Here is one of my Multiple Thing array:

[
    {
        "id": "urn:dev:ops:28-01131b711e04",
        "title": "Temperature Sensor 1",
        "@context": "https://iot.mozilla.org/schemas",
        "@type": [
            "TemperatureSensor"
        ],
        "properties": {
            "level": {
                "@type": "TemperatureProperty",
                "title": "Temperature",
                "type": "number",
                "description": "The current temperature in \u00b0C",
                "unit": "degree celsius",
                "readOnly": true,
                "links": [
                    {
                        "rel": "property",
                        "href": "/0/properties/level"
                    }
                ]
            }
        },
        "actions": {},
        "events": {},
        "links": [
            {
                "rel": "properties",
                "href": "/0/properties"
            },
            {
                "rel": "actions",
                "href": "/0/actions"
            },
            {
                "rel": "events",
                "href": "/0/events"
            },
            {
                "rel": "alternate",
                "href": "ws://heizung-og.local:8888/0"
            }
        ],
        "description": "a web connected temperature sensor",
        "href": "/0",
        "base": "http://heizung-og.local:8888/0",
        "securityDefinitions": {
            "nosec_sc": {
                "scheme": "nosec"
            }
        },
        "security": "nosec_sc"
    },
    {
        "id": "urn:dev:ops:28-01131bc14987",
        "title": "Temperature Sensor 2",
        ...

The WebSocket API is not intended to replace the REST API, only complement it. The proper thing to do (which the Web Thing add-on does) is to read the thing description first to get the list of properties/actions/event, as well as the metadata (like the title), before opening the WebSocket connection.

1 Like