Git Product home page Git Product logo

goopenzwave's Introduction

goopenzwave

Go bindings for the OpenZWave library.

Warning

This package is still fairly new and so the API is changing pretty rapidly, so be careful if you decide to use it. However, the API will try to mimic the C++ OpenZWave library as much as possible, if it doesn't already, so there shouldn't be many breaking changes.

Most of the C++ OpenZWave library is wrapped now, but should you find anything missing please create a new issue or fork it, implement it yourself and submit a pull request.

Installing OpenZWave

This package requires a system installation of OpenZWave. pkg-config is then used during the build of this package to get the open-zwave library and headers.

Note that package managers may install an old version of the library so a manual build/install from source is preferred.

Example install from source:

  1. git clone https://github.com/OpenZWave/open-zwave.git
  2. cd open-zwave
  3. make -j$(nproc)
  4. sudo make install
  5. You may need to call sudo ldconfig now on linux systems
  6. See the open-zwave/INSTALL file for more information

Get the Package

go get github.com/jimjibone/goopenzwave

Example: gominozw

This package comes with a basic example, gominozw, which is a replica of the original C++ OpenZWave MinOZW utility, now written in Go.

It shows how to set up the Manager with various options and listen for Notifications. Once the initial scan of devices is complete, polling for basic values is set up for the devices.

To install and use:

go install github.com/jimjibone/goopenzwave/gominozw
gominozw --controller /dev/ttyYourUSBDevice

Notes

open-zwave build fails with fatal error: libudev.h: No such file or directory on Debian/Ubuntu

Try installing libudev with apt and build again.

apt-get install libudev-dev
cd open-zwave && make

Crashes instantly on macOS 10.12

Do you see something like this when trying to run something with the goopenzwave package?

$ ./gominozw -h
zsh: killed     ./gominozw -h

You should try building with the -ldflags=-s option. E.g.: go build -ldflags=-s. More info at golang/go#19734.

goopenzwave's People

Contributors

jimjibone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

goopenzwave's Issues

Rename gozwctl to just gozw

A simpler name, typing gozwctl is a pain...

Also, the binary should be called gozwd, as it is a server and will be mainly run as a daemon.

Upgrade to latest OpenZWave library

The latest version of the library contains a lot of changes from v1.5 that this Go wrapper utilises. These changes contain updates thanks to the public release of the ZWave spec and numerous updates to the device database.

Add a quick example

For godoc to show...

Add a file: goopenzwave_test.go

Add something(s) like this:

func Example_basic() {
    err := foo.Bar()
    if err != nil {
        panic(err)
    }
}

More info

/usr/bin/ld: cannot find -lopenzwave

First, thank you for this very interesting library. I'm trying to get it to work on Ubuntu 17.04 for a home automation project, but run into a build problem.

Following the instructions in the readme

  1. git submodule update --init
  2. cd open-zwave
  3. PREFIX=$(pwd)/../.lib/ make install

Step 3 results in "install: cannot create directory โ€˜//usr/local/lib/x86_64-linux-gnuโ€™: Permission denied"
This is because it is not run as root, I thought the use of PREFIX would install it locally. I realize this is an openzwave thing and maybe this is fine, if so, it would be nice to have a comment in the doc.

Ignoring that error for now, after installing gominozw running
go run gominozw.go there is a linking error:
"/usr/bin/ld: cannot find -lopenzwave"

Looking into gooopenzwave_linux.go the #cgo LDFLAGS contains the library "-L${SRCDIR}/.lib/lib -l openzwave", however the library folder created by openzwave's make install is called lib64 instead of lib.

Can you suggest the best way to solve this?
Thanks!

Add notifications to web ui

When an update to a node comes in from the server (after the initial scan) display a notification on the screen.

Push Nodes/Manager/etc into subdirectories

The current goopenzwave package is very cluttered and could probably benefit from pushing the various files into their own packages and then splitting the files appropriately.

Change API bool returns to error where appropriate

The C++ OpenZWave returns a bool in some cases to indicate success/failure. It is idiomatic in Go to return the error type to represent this.

Functions that return a bool to show success/failure should instead use error.

Replace old package names with new one

This repository used to live on GitLab, now it lives here on GitHub.

Rename all instances of gitlab.com/jimjibone/gozwave with github.com/jimjibone/goopenzwave.

Also look for any remaining gozwave strings and replace with goopenzwave.

Add license

Think I'll go for the MIT license.

The MIT License (MIT)

Copyright (c) 2015 James Reuss <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Use system OZW installation

As suggested in #21, switch to a system installation of OZW.

Original reason to bundle OZW as a submodule was to use a fixed version with goopenzwave, however this is not necessary as recent releases of OZW have shown to be backwards compatible.

Using an up-to-date system installation of OZW would be preferable as this library will benefit from the improvements and it can share configuration, etc. with other OZW based software such as the open-zwave-control-panel.

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.