Skip to content

Homebridge plugin to interface with any modbusTCP

Notifications You must be signed in to change notification settings

ljia310/homebridge-modbus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

homebridge-modbus

Hombridge plugin for controlling appliances through ModbusTCP

You must define each accessory in the config.json file, with a name, a type (that matches any HomeKit Service type), and one or more characteristics (that match HomeKit Characteristics for this Service). If you want to group several services under the same accessory, just reuse the same accessory name, and add a subtype field if services are of the same type. The characteristics value in the json is the modbus address associated with it. Coils are defined with the letter 'c' followed by the coil number, holding registers are defined with the letter 'r' followed by the register number, input registers are defined with the letter 'i' followed by the register number.

If you want more advanced control, the characteristic value can instead be an object having address as the coil/register type and number, and optional elements like validValues, maxValue, value to configure HomeKit, mask and/or map to map different values between modbus and homekit, readOnly to force holding registers or coils to not be written on modbus (input registers are always read-only).

服务类型: https://developer.apple.com/documentation/homekit/hmservicetypelightbulb https://github.com/homebridge/HAP-NodeJS/blob/master/src/lib/gen/HomeKit.ts 服务参数类型定义: https://github.com/homebridge/HAP-NodeJS/blob/master/src/lib/definitions/CharacteristicDefinitions.ts

Example config.json:

{
    "bridge": {
        "name": "Homebridge saftop",
        "username": "0E:61:24:A7:10:4B",
        "port": 51345,
        "pin": "918-71-753"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "c",
            "lang": "auto",
            "sudo": true,
            "debug": true,
            "accessoryControl": {
                "debug": false
            },
            "platform": "config"
        },
        {
            "platform": "Modbus",
            "ip": "20.0.0.251",
            "port": 502,
            "modbus_mode": 1,
            "pollFrequency": 3000,
            "accessories": [
                {
                    "name": "电梯厅1人感",
                    "type": "MotionSensor",
                    "MotionDetected": {
                        "address": "r27",
                        "map": {
                            "0": false,
                            "1": true,
                            "2": false
                        }
                    }
                },
                {
                    "name": "电梯厅2人感",
                    "type": "MotionSensor",
                    "MotionDetected": {
                        "address": "r28",
                        "map": {
                            "0": false,
                            "1": true,
                            "2": false
                        }
                    }
                },
                {
                    "name": "研发南人感",
                    "type": "MotionSensor",
                    "MotionDetected": {
                        "address": "r30",
                        "map": {
                            "0": false,
                            "1": true,
                            "2": false
                        }
                    }
                },
                {
                    "name": "研发北人感",
                    "type": "MotionSensor",
                    "MotionDetected": {
                        "address": "r29",
                        "map": {
                            "0": false,
                            "1": true,
                            "2": false
                        }
                    }
                },
                {
                    "name": "湿度",
                    "type": "HumiditySensor",
                    "CurrentRelativeHumidity": {
                        "address": "r160",
                        "len": 2
                    }
                },
                {
                    "name": "温度",
                    "type": "TemperatureSensor",
                    "CurrentTemperature": {
                        "address": "r158",
                        "len": 2
                    }
                },
                {
                    "name": "研发灯带",
                    "type": "Lightbulb",
                    "On": {
                        "address": "r83",
                        "len": 1,
                        "map": {
                            "0": false,
                            "100": true
                        }
                    }
                },
                {
                    "name": "研发北",
                    "type": "Lightbulb",
                    "On": {
                        "address": "r81",
                        "len": 1,
                        "map": {
                            "0": false,
                            "100": true
                        }
                    }
                },
                {
                    "name": "研发区南",
                    "type": "Lightbulb",
                    "On": {
                        "address": "r82",
                        "len": 1,
                        "map": {
                            "0": false,
                            "100": true
                        }
                    }
                }
            ]
        },
        {
            "platform": "Modbus",
            "ip": "20.0.0.208",
            "port": 502,
            "modbus_mode": 1,
            "pollFrequency": 3000,
            "accessories": [
                {
                    "name": "光照度",
                    "type": "LightSensor",
                    "CurrentAmbientLightLevel": {
                        "address": "r5",
                        "len": 1
                    }
                }
            ]
        },
        {
            "cameras": [
                {
                    "name": "公司大门摄像头",
                    "videoConfig": {
                        "source": "-re -i rtsp://admin:saftop9854@20.0.2.2:554/h264/ch36/sub/av_stream"
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        }
    ]
}

About

Homebridge plugin to interface with any modbusTCP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%