bwssytems / ha-bridge

Home automation bridge that emulates a Philips Hue light system and can control other systems such as a Vera, Harmony Hub, Nest, MiLight bulbs or any other system that has an http/https/tcp/udp interface. This is a compact impl to run on small format computers. This is impl started from this project https://github.com/armzilla/amazon-echo-ha-bridge.
Apache License 2.0
1.45k stars 198 forks source link

How do I setup a Mozilla IoT device #1183

Open zabaya opened 4 years ago

zabaya commented 4 years ago

I've setup succesfully the bridge to ha-bridge i can see all the bridged devices but the on/off/dim/color state section is a mystery for me. I've searched in the faq between all the issues. But can't seem to get it to work.

bwssytems commented 4 years ago

Did you install the Mozilla IOT Gateway shown here https://iot.mozilla.org/gateway/ ?

zabaya commented 4 years ago

Yes on a separate pi

bwssytems commented 4 years ago

Did you put in that information on the Bridge Control Tab for the Mozilla IOT gateway so it can bring up the helper?

zabaya commented 4 years ago

Yes, I've successfully connected a hub, I can see the devices on the hub:

Screen Shot 2020-03-08 at 17 55 10

Let's say I want to add the Bulb, what do I fill in these fields:

Screen Shot 2020-03-08 at 18 03 09

I feel like a noob, usually I can figure stuff like this out, but now I don't know what I'm doing wrong. I also tried to use Postman and this example to see what is what. If I send the same command to through that then I get an error.

Screen Shot 2020-03-08 at 18 14 35

So basicly I'm stuck.

zabaya commented 4 years ago

Alright so I got a little bit further. I found out that my property links were wrong so I now can successfully send commands through Postman without error's:

PUT http://gateway.local/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17/properties/17-17 contenttype: application/json

body: {"17-17":50} will set the bulb to 50%

Screen Shot 2020-03-08 at 20 26 13

But now i don't know what to fill in where in ha-bridge.

Here is all the info i got with the GET method:

{
        "title": "Bulb",
        "@context": "https://iot.mozilla.org/schemas",
        "@type": [
            "Light",
            "OnOffSwitch"
        ],
        "description": "Default-Model",
        "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17",
        "properties": {
            "17-16": {
                "title": "On",
                "type": "boolean",
                "@type": "OnOffProperty",
                "description": "On",
                "links": [
                    {
                        "rel": "property",
                        "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17/properties/17-16"
                    }
                ]
            },
            "17-17": {
                "title": "Brightness",
                "type": "integer",
                "@type": "BrightnessProperty",
                "unit": "percent",
                "description": "Brightness",
                "minimum": 0,
                "maximum": 100,
                "multipleOf": 1,
                "links": [
                    {
                        "rel": "property",
                        "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17/properties/17-17"
                    }
                ]
            }
        },
        "actions": {},
        "events": {},
        "links": [
            {
                "rel": "properties",
                "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17/properties"
            },
            {
                "rel": "actions",
                "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17/actions"
            },
            {
                "rel": "events",
                "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17/events"
            },
            {
                "rel": "alternate",
                "mediaType": "text/html",
                "href": "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17"
            },
            {
                "rel": "alternate",
                "href": "ws://gateway.local/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17"
            }
        ],
        "layoutIndex": 3,
        "selectedCapability": "Light",
        "iconHref": null,
        "id": "http://gateway.local/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17",
        "base": "http://gateway.local/",
        "securityDefinitions": {
            "oauth2_sc": {
                "scheme": "oauth2",
                "flow": "code",
                "authorization": "http://gateway.local/oauth/authorize",
                "token": "http://gateway.local/oauth/token",
                "scopes": [
                    "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17:readwrite",
                    "/things/homekit-CC%3A22%3A3D%3AE3%3ACE%3A31-17",
                    "/things:readwrite",
                    "/things"
                ]
            }
        },
        "security": "oauth2_sc"
    }
bwssytems commented 4 years ago

Once you hit build item and it goes to the screen with the details, just hit the save device at the top of the screen and then it adds it with the correct commands. It is then available the devices tab. The helper sets it up for you.

zabaya commented 4 years ago

I've tried that, but it doesn't do anything. It sees the device, and if i click add, it doesn't work. I even tried to make it work like this with an bearer authorization like this one. I send both screenshots and logs:

Mozilla log:

HTTP response code was not an expected successful response of between 200 - 299, the code was: HTTP/1.1 400 Bad Request with the content of <<<Invalid property name>>>

But it is exactly the same as the Postman method I've send earlier

Screen Shot 2020-03-10 at 20 04 05

HTTP log:

On/Off Request failed with: [{"error":{"type":"6","address":"/lights/108","description":"Error on calling url to change device state","method_name":"/lights/108/state"}}]

Same as above

Screen Shot 2020-03-10 at 19 55 09
bwssytems commented 4 years ago

will need to take a look