bridge

package module
v0.0.0-...-8f13b60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2018 License: Unlicense Imports: 9 Imported by: 0

README

MQTTHomekitBridge

Bridge devices which communicate by MQTT to standard HomeKit devices, such that they then become available to use on iOS devices.

Use case

Various devices communicate in my home using simple MQTT topic and payload messages, which are managed using Mosquitto as the broker. Messages are of the form below, but could change at any moment to a different form:

home/bedroom/temp = 29.18
home/bedroom/light = 14

home/balcony/light = 49
home/balcony/humi = 1.00
home/balcony/temp = 26.90
home/balcony/battery = 3160

home/lounge/pressure = 1004.38
home/lounge/battery = 3260
home/lounge/light = 90
home/lounge/temp = 26.60

It would be nice to have a method of linking arbitrary message data to HomeKit accessory devices, via a configuration file of some form. Flexibility in message topic and payloads would also be useful to minimise the cases where a change of device impacts the ability to bridge.

Config

A simple config file should allow mapping the devices to be bridged. TOML may be one method of encoding these details.

# Configuration of MQTT devices to be bridged

#pin = "10340567"
broker = "192.168.1.22:1883"
bridgename = "MacMQTTBridge"

[[devices.temperaturesensor]]
displayname = "Balcony Temperature"
topic = "home/balcony/temp"

[[devices.temperaturesensor]]
displayname = "Lounge Temperature"
topic = "home/lounge/temp"

[[devices.lightsensor]]
displayname = "Balcony Light"
topic = "home/balcony/light"

[[devices.lightsensor]]
displayname = "Lounge Light"
topic = "home/lounge/light"

Build

On the raspberry pi this can be built using the following

go get -u github.com/danward79/MQTTHomekitBridge
cd $GOPATH/src/github.com/danward79/MQTTHomekitBridge/cmd
GOOS=linux GOARCH=arm GOARM=7 go build

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AccessoryTypes = []string{"temperaturesensor", "lightsensor"}

AccessoryTypes stores a list of available accessory device types for the bridge

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	*accessory.Accessory
	// contains filtered or unexported fields
}

Bridge stores details of a bridge

func New

func New(brokerIP, pin, name, model, manufacturer string) *Bridge

New provides a new bridge device for accepting services.

func (*Bridge) DisableLogs

func (b *Bridge) DisableLogs()

DisableLogs detailed debug logs

func (*Bridge) EnableLogs

func (b *Bridge) EnableLogs()

EnableLogs detailed debug logs

func (*Bridge) Start

func (b *Bridge) Start(devices *[]BridgeableDevice)

Start transport

type BridgeableDevice

type BridgeableDevice interface {
	Update([]byte) error
	Service() *service.Service
	Acc() *accessory.Accessory
	Topic() string
}

BridgeableDevice is a device that can be bridged between homekit and mqtt

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL