{"id":16408664,"url":"https://github.com/creativeprojects/go-homie","last_synced_at":"2025-04-13T20:14:32.055Z","repository":{"id":57546979,"uuid":"301487628","full_name":"creativeprojects/go-homie","owner":"creativeprojects","description":"Homie for MQTT convention library","archived":false,"fork":false,"pushed_at":"2024-04-25T15:38:47.000Z","size":47,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T20:14:25.527Z","etag":null,"topics":["go","golang","homie","iot","mqtt","mqtt-homie"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creativeprojects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-05T17:28:35.000Z","updated_at":"2025-01-02T16:02:29.000Z","dependencies_parsed_at":"2024-04-25T16:45:59.323Z","dependency_job_id":null,"html_url":"https://github.com/creativeprojects/go-homie","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativeprojects%2Fgo-homie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativeprojects%2Fgo-homie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativeprojects%2Fgo-homie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativeprojects%2Fgo-homie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creativeprojects","download_url":"https://codeload.github.com/creativeprojects/go-homie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248774968,"owners_count":21159534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","homie","iot","mqtt","mqtt-homie"],"created_at":"2024-10-11T06:17:29.275Z","updated_at":"2025-04-13T20:14:32.033Z","avatar_url":"https://github.com/creativeprojects.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/creativeprojects/go-homie.svg)](https://pkg.go.dev/github.com/creativeprojects/go-homie)\n[![Build](https://github.com/creativeprojects/go-homie/actions/workflows/build.yml/badge.svg)](https://github.com/creativeprojects/go-homie/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/creativeprojects/go-homie/graph/badge.svg?token=CLCV5OHNP5)](https://codecov.io/gh/creativeprojects/go-homie)\n[![Go Report Card](https://goreportcard.com/badge/github.com/creativeprojects/go-homie)](https://goreportcard.com/report/github.com/creativeprojects/go-homie)\n\n# Homie convention for Go\n\nThe [Homie convention](https://homieiot.github.io/) defines a standardized way of how IoT devices and services announce themselves and their data on the MQTT broker.\n\nThis library is MQTT implementation agnostic: it only generates and manages topics and values, not actually sending them through the wire.\n\nSee an example on how to define a Homie device:\n\n``` go\ndevice := homie.NewDevice(\"my-sensor\", \"MQTT ESP8266 agent\")\ndevice.\n    AddNode(\"bme280\", \"BME280 via ESP8266EX\", \"bme280\").\n    AddProperty(\"temperature\", \"Temperature\", homie.TypeFloat).SetUnit(\"°C\").Node().\n    AddProperty(\"pressure\", \"Pressure\", homie.TypeFloat).SetUnit(\"hPa\").Node().\n    AddProperty(\"humidity\", \"Humidity\", homie.TypeFloat).SetUnit(\"%\")\n```\n\nSend the Homie attributes and or values to the MQTT client:\n\n```go\n// all homie attributes\nfor _, attribute := range device.GetHomieAttributes() {\n    publish(attribute.Topic, attribute.Value)\n}\n\n// all property values\nfor _, attribute := range device.GetValues() {\n    if attribute.Value != \"\" {\n        publish(attribute.Topic, attribute.Value)\n    }\n}\n```\n\nYour `publish` function can use the MQTT client of your choice.\n\nYou can set a callback for sending property values for you when you set them:\n\n```go\nfunc onSet(topic, value string, dataType homie.PropertyType) {\n    if value == \"\u003cnil\u003e\" {\n        value = \"\"\n    }\n    if value == \"\" \u0026\u0026 dataType != homie.TypeString {\n        // don't send a blank string on anything else than a string data type\n        return\n    }\n    publish(topic, value)\n}\n\n// either install a global callback on the device...\ndevice.OnSet(onSet)\n\n// ...or install the callback on this property only\ndevice.Node(\"bmp280\").Property(\"temperature\").OnSet(onSet)\n\n// new values will be published for you\ndevice.Node(\"bme280\").Property(\"temperature\").Set(20.0)\n\n```\n\n## Supported extensions\n\n### Legacy Firmware\n\nSee [Specifications](https://github.com/homieiot/convention/blob/develop/extensions/documents/homie_legacy_firmware_extension.md)\n\n```go\ndevice := NewDevice(\"deviceID\", \"deviceName\")\ndevice.AddExtension(NewLegacyFirmware(\"C0:FF:EE:01\", \"192.168.26.5\", \"awesome-firmware\", \"version\"))\n```\n\n### Legacy Stats\n\nSee [Specifications](https://github.com/homieiot/convention/blob/develop/extensions/documents/homie_legacy_stats_extension.md)\n\n```go\nstats := NewLegacyStats()\nNewDevice(\"deviceID\", \"deviceName\").\n    AddExtension(stats).\n    OnSet(onSet)\n\nstats.\n    SetInterval(60).\n    SetUptime(0)\n```\n## More information\n\nSee the [example](https://github.com/creativeprojects/go-homie/blob/main/example/main.go)\n\nSee [go doc](https://pkg.go.dev/github.com/creativeprojects/go-homie)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreativeprojects%2Fgo-homie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreativeprojects%2Fgo-homie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreativeprojects%2Fgo-homie/lists"}