Giter Club home page Giter Club logo

homebridge-modbus's Introduction

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:[email protected]:554/h264/ch36/sub/av_stream"
                    }
                }
            ],
            "platform": "Camera-ffmpeg"
        }
    ]
}

homebridge-modbus's People

Contributors

ljia310 avatar sclavel avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.