在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:cflurin/homebridge-mqtt开源软件地址:https://github.com/cflurin/homebridge-mqtt开源编程语言:JavaScript 100.0%开源软件介绍:homebridge-mqttHomebridge-mqtt is a Plugin for Homebridge. The design is based on MVC pattern, have a look at homebridge-mvc. Homebridge-mqtt is a dynamic Plugin that allows you to add and control accessories from a "Bridge" or "Device" with a mqtt API. Node-RED is the perfect platform to use with homebridge-mqtt. Note-RED is a visual tool for wiring together hardware devices, APIs and online services. InstallationIf you are new to Homebridge, please first read the documentation to install Homebridge. Install the homebridge-mqtt plugin through Homebridge Config UI X. Configuration/SettingGo to Homebridge Config UI X, select
"platforms": [
{
"platform": "mqtt",
"name": "mqtt",
"url": "mqtt://127.0.0.1",
"port": "1883",
"username": "foo",
"password": "bar",
"qos": 1,
"cert": "/path/to/certificate.pem",
"key": "path/to/key.pem",
"ca": "/path/to/ca_certificate.pem",
"client_id": "some-string",
"topic_type": "multiple",
"topic_prefix": "homebridge"
}
] Replace topic_type topic : homebridge/from/set topic_type topic : homebridge/from/set/flex_lamp mqtt APIThe data (payload) is sent/received in a JSON format using following topics:
Version 0.3.0 and higher supports Note: To add a service to an existing accessory (created prior version 0.3.0) please first remove the accessory and add it again. Note 2: Optional parameter request_id : 4711 Howto examplesadd accessorytopic: homebridge/to/add
payload: {"name": "flex_lamp", "service_name": "light", "service": "Switch"} or with the additional accessory informations topic: homebridge/to/add
payload:
{
"name": "flex_lamp",
"service_name": "light",
"service": "Switch",
"manufacturer": "lamp_manu",
"model": "flex_007",
"serialnumber": "4711",
"firmwarerevision": "1.0.0"
} response: topic: homebridge/from/response
payload: {"ack": true, "message": "accessory 'flex_lamp' service_name 'light' is added."} add serviceNote: an accessory with the same topic: homebridge/to/add/service
payload: {"name": "multi_sensor", "service_name": "humidity", "service": "HumiditySensor"} response: topic: homebridge/from/response
payload: {"ack": true, "message": "service_name 'humidity', service 'HumiditySensor' is added."} remove accessorytopic: homebridge/to/remove
payload: {"name": "flex_lamp"} response: topic: homebridge/from/response
payload: {"ack": true, "message": "accessory 'flex_lamp' is removed."} remove servicetopic: homebridge/to/remove/service
payload: {"name": "multi_sensor", "service_name": "humidity"} response: topic: homebridge/from/response
payload: {"ack": true, "message": "accessory 'multi_sensor' service_name 'humidity' is removed."} get accessory/accessoriesThe purpose of this topic is to retrieve accessory configurations.
Use topic: homebridge/to/get
payload: {"name": "outdoor_temp"} homebridge sends the accessory configuration: topic: homebridge/from/response
payload:
{
"outdoor_temp": {
"services": {
"Temperature": "TemperatureSensor"
},
"characteristics": {
"Temperature": {
"CurrentTemperature": 13.4
}
}
}
} topic: homebridge/to/get
payload: {"name": "*"} homebridge sends all accessory configurations: topic: homebridge/from/response
payload:
{
"node_switch": {
"services": {
"light": "Switch"
},
"characteristics": {
"Light": {
"On": true
}
}
},
"office_lamp": {
"services": {
"office_light": "Lightbulb"
},
"characteristics": {
"office_light": {
"On": "blank",
"Brightness": 65
}
}
},
"living_temp": {
"services": {
"living_temperature": "TemperatureSensor"
},
"characteristics": {
"living_temperature": {
"CurrentTemperature": 19.6
}
}
}
} topic: homebridge/to/get
payload: {"name": "*_props"} homebridge sends all accessory configurations, including properties: topic: homebridge/from/response
payload:
{
"node_switch": {
"services": {
"light": "Switch"
},
"characteristics": {
"Light": {
"On": true
}
},
"properties": {
"Light": {
"On": {
"format": "bool",
"unit": null,
"minValue": null,
"maxValue": null,
"minStep": null,
"perms": [
"pr",
"pw",
"ev"
]
}
}
},
"office_lamp": {
"services": {
"office_light": "Lightbulb"
},
"characteristics": {
"office_light": {
"On": "blank",
"Brightness": 65
}
},
"properties": {
"office_light": {
"On": {
"format": "bool",
"unit": null,
"minValue": null,
"maxValue": null,
"minStep": null,
"perms": [
"pr",
"pw",
"ev"
]
},
"Brightness": {
"format": "int",
"unit": "percentage",
"minValue": 0,
"maxValue": 100,
"minStep": 1,
"perms": [
"pr",
"pw",
"ev"
]
}
}
}
},
"living_temp": {
"services": {
"living_temperature": "TemperatureSensor"
},
"characteristics": {
"living_temperature": {
"CurrentTemperature": 19.6
}
},
"properties": {
"living_temperature": {
"CurrentTemperature": {
"format": "float",
"unit": "celsius",
"minValue": 0,
"maxValue": 100,
"minStep": 0.1,
"perms": [
"pr",
"ev"
]
}
}
}
}
}
} set value (to homebridge)topic: homebridge/to/set
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On", "value": true} get value (from homebridge)topic: homebridge/from/get
payload: {"name": "flex_lamp", "service_name": "light", "service_type":"Switch", "characteristic": "On", "cachedValue": true} Homebridge-mqtt will return the cached value to HomeKit. Optionally you can publish the actual value using
set value (from homebridge)topic: homebridge/from/set
payload: {"name": "flex_lamp", "service_name": "light", "service_type":"Switch", "characteristic": "On", "value": true} get (cached) value (to homebridge)topic: homebridge/to/get/characteristic
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On"} response: topic: homebridge/from/response
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On", "cachedValue": true} set reachabilitytopic: homebridge/to/set/reachability
payload: {"name": "flex_lamp", "reachable": true}
or
payload: {"name": "flex_lamp", "reachable": false} set accessory informationtopic: homebridge/to/set/accessoryinformation
payload: {"name": "flex_lamp", "manufacturer": "espressif", "model": "esp8266-12", "serialnumber": "4711", "firmwarerevision": "1.1.0"} identify accessorytopic: homebridge/from/identify
payload: {"name":"indoor_temp","manufacturer":"homebridge-mqtt","model":"v0.3.0","serialnumber":"2017-02-13T12:17"} define charactersticThe required characteristics are added with the default properties. If you need to change the default, define the characteristic-name with the properties. e.g.: topic: homebridge/to/add
payload:
{
"name": "living_temp",
"service_name": "temperature",
"service": "TemperatureSensor",
"CurrentTemperature": {"minValue": -20, "maxValue": 60, "minStep": 1}
} To add an optional charachteristic define the characteristic-name with "default" or with the properties. e.g.: topic: homebridge/to/add
payload:
{
"name": "living_lamp",
"service_name": "light",
"service": "Lightbulb",
"Brightness": "default"
} topic: homebridge/to/add
payload:
{
"name": "bathroom_blind",
"service_name": "blind",
"service": "WindowCovering",
"CurrentPosition": {"minStep": 5},
"TargetPosition": {"minStep": 5},
"CurrentHorizontalTiltAngle": {"minValue": 0, "minStep": 5},
"TargetHorizontalTiltAngle": {"minValue": 0, "minStep": 5}
} HomeKit.ts describes all the predifined Services, Characteristcs, format and properties for the
Derived from this:
Node-red exampleFor more examples take a look at the wiki |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论