iRayanKhan / homebridge-tuya

A Homebridge plugin to control Tuya devices locally.
MIT License
394 stars 164 forks source link

How to add the device in Homekit app ? #46

Closed lemaygabriel closed 4 years ago

lemaygabriel commented 5 years ago

Here's what I get when I start HomeBridge:

[2019-2-18 15:56:57] Loaded config.json with 1 accessories and 0 platforms. [2019-2-18 15:56:57] --- [2019-2-18 15:56:57] Loaded plugin: homebridge-garage-gate-opener [2019-2-18 15:56:57] Registering accessory 'homebridge-garage-gate-opener.GarageGateOpener' [2019-2-18 15:56:57] --- [2019-2-18 15:56:58] Loaded plugin: homebridge-tuya [2019-2-18 15:56:58] Registering platform 'homebridge-tuya.TuyaPlatform' [2019-2-18 15:56:58] --- [2019-2-18 15:56:59] Loading 1 accessories... [2019-2-18 15:56:59] [Garage] Initializing GarageGateOpener accessory... [2019-2-18 15:56:59] [Garage] GarageGateOpenerAccessory version 0.0.8 [2019-2-18 15:56:59] [Garage] WARN! WARN! WARN! may not be able to control GPIO pins because not running as root! [2019-2-18 15:56:59] [Garage] Switch Pin: 23 [2019-2-18 15:56:59] [Garage] Switch Val: ACTIVE_HIGH [2019-2-18 15:56:59] [Garage] Switch Active Time in ms: 800 [2019-2-18 15:56:59] [Garage] Closed Sensor: Configured [2019-2-18 15:56:59] [Garage] Closed Sensor Pin: 24 [2019-2-18 15:56:59] [Garage] Closed Sensor Val: ACTIVE_HIGH [2019-2-18 15:56:59] [Garage] Open Sensor: Configured [2019-2-18 15:56:59] [Garage] Open Sensor Pin: 25 [2019-2-18 15:56:59] [Garage] Open Sensor Val: ACTIVE_HIGH [2019-2-18 15:56:59] [Garage] Sensor Poll in ms: 4000 [2019-2-18 15:56:59] [Garage] Opens in seconds: 20 [2019-2-18 15:56:59] [Garage] We have a sensor, monitoring state enabled. [2019-2-18 15:56:59] [Garage] Initial State: CLOSED [2019-2-18 15:56:59] [Garage] Setting state to 1 Load homebridge-tuya.TuyaPlatform Setup Payload: X-HM://0023ORIRA60F1 Scan this code with your HomeKit app on your iOS device to pair with Homebridge: XXXX Or enter this code with your HomeKit app on your iOS device to pair with Homebridge: XXXX
events.js:112 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::52460 at Server.setupListenHandle [as _listen2] (net.js:1361:14) at listenInCluster (net.js:1402:12) at Server.listen (net.js:1490:7) at EventedHTTPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19) at HAPServer.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:158:20) at Bridge.Accessory.publish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:609:16) at Server._publish (/usr/local/lib/node_modules/homebridge/lib/server.js:128:16) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:97:10) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:45:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)

Here's my config.json file:

{ "bridge": { "name": "Homebridge_MForge", "username": "A1:BC:XX:XX:XX:XX", "port": 52XXX, "pin": "XXX-XX-XXX" },

    "accessories": [{
            "accessory": "GarageGateOpener",
            "name": "Garage",
            "switchPin": 23,
            "switchPressTimeInMs": 800,
            "switchValue": 1,
            "closedSensorPin": 24,
            "closedSensorValue": 1,
            "openSensorPin": 25,
            "openSensorValue": 1,
            "pollInMs": 4000,
            "opensInSeconds": 20
    }],

    "platform": "TuyaPlatform",
    "name": "TuyaPlatform",
    "devices": [{
                    "name": "Tuya Outlet Device 1",
                    "id": "45412206dc4f22e1XXXX,
                    "key": "fb27a3b1d226XXXX"
            },
            {
                    "name": "Tuya Dimmer Switch Device 2",
                    "id": "45412206dc4f22e1XXXX",
                    "key": "fb27a3b1d226XXXX",
                    "type": "dimmer"
            }
    ]

}

Am I doing this right ? I can't figure out how to add my device in the Homekit App. I'm using a CE smart switch with the Tuya Smart App. Everything work in the Tuya app. Thanks ! :)

codetheweb commented 5 years ago

TuyAPI doesn't use that port; so I suspect something else is wrong. Maybe try rebooting your system?

Try removing the TuyaPlatform from your config.json and see if Homebridge starts.

soorb commented 5 years ago

Some errors in your Json code. When you want to see if your code works, go to https://jsonlint.com/ and paste it in the window and press validate json.

but try this

{ "bridge": { "name": "Homebridge_MForge", "username": "A1:BC:XX:XX:XX:XX", "port": 52XXX, "pin": "XXX-XX-XXX" }, "accessories": [{ "accessory": "GarageGateOpener", "name": "Garage", "switchPin": 23, "switchPressTimeInMs": 800, "switchValue": 1, "closedSensorPin": 24, "closedSensorValue": 1, "openSensorPin": 25, "openSensorValue": 1, "pollInMs": 4000, "opensInSeconds": 20 }],

"platform": "TuyaPlatform",
"name": "TuyaPlatform",
"devices": [{
        "name": "Tuya Outlet Device 1",
        "id": "45412206dc4f22e1XXXX",
        "key": "fb27a3b1d226XXXX",
                     "type": "generic"
    },
    {
        "name": "Tuya Dimmer Switch Device 2",
        "id": "45412206dc4f22e1XXXX",
        "key": "fb27a3b1d226XXXX",
        "type": "dimmer"
    }
]

}

You can also ad "ip" if the plugin has a problem finding your switches

like this

{ "bridge": { "name": "Homebridge_MForge", "username": "A1:BC:XX:XX:XX:XX", "port": 52XXX, "pin": "XXX-XX-XXX" }, "accessories": [{ "accessory": "GarageGateOpener", "name": "Garage", "switchPin": 23, "switchPressTimeInMs": 800, "switchValue": 1, "closedSensorPin": 24, "closedSensorValue": 1, "openSensorPin": 25, "openSensorValue": 1, "pollInMs": 4000, "opensInSeconds": 20 }],

"platform": "TuyaPlatform",
"name": "TuyaPlatform",
"devices": [{
        "name": "Tuya Outlet Device 1",
        "id": "45412206dc4f22e1XXXX",
        "key": "fb27a3b1d226XXXX",
        "ip": "xxx.xxx.x.101",
                     "type": "generic"
    },
    {
        "name": "Tuya Dimmer Switch Device 2",
        "id": "45412206dc4f22e1XXXX",
        "key": "fb27a3b1d226XXXX",
        "ip": "xxx.xxx.x.102",
        "type": "dimmer"
    }
]

}

codetheweb commented 5 years ago

(I'm copy/pasting this into every open issue and PR.)

This plugin is now deprecated, as I don't have enough time to maintain it along with other TuyAPI related projects. Please use AMoo-Miki's homebridge-tuya-lan plugin instead. (Or, you can continue to use this plugin, but I will not be giving support or adding any new devices.)

I'm sorry about this, but this plugin is taking a disproportionate amount of my time that I believe is better spent making TuyAPI more stable and adding more tools to the ecosystem.