Giter Site home page Giter Site logo

gbridge's People

Contributors

localleon avatar pborges avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

gbridge's Issues

Create GoDoc

To improve the usability of this libary, one should create a GoDoc. This could also improve adoption.

Currently all librarys, even the ones from Google are badly documented and hard to understand. Our goal should be to provide a simple and well documented library.

Do "Executions" in parallel

Commands like "turn on all the lights" can fire off many requests that take too long and time out, making google say gbridge failed, so lets execute all the Executions in parallel.

https

Hi, it doesn't work, seems it need certificate files for SSL and aouth.

Add a license

Under which terms/conditions can people use this project?

An MIT License would be great.

Devices from Example not showing Up

Hey @pborges ,

thank you for creating this libary. I'm currently trying to create a simple Google Actions Skill with it.

However i'm not able to get your example to work. The Action shows up on my Google Home Skill and i can get an Oauth Token from it. But after that, nothing happens. I expected the defined devices to show up in the Google Home App. The gBridge did not log an SYNC Request either.

Would be great if you could take a look at my code. I'm using a ngrok Tunnel for communication between the cloud and my pc.

package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/gorilla/mux"
	"github.com/pborges/gbridge"
)

var addr = ":8081"

func main() {
	log.SetOutput(os.Stdout)
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	r := mux.NewRouter()

	r.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		log.Println("UNKKNOWN:", r.RequestURI)
	})

	r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		log.Println("/")
		fmt.Fprint(w, "gAssistant Translator for S.A.M Online")
	})

	b := gbridge.Bridge{
		ClientId:     "950e4dcfe43dc656bd7caa4f8da05fb0", //as long as this matches the settings "Account linking" on actions console it works
		ClientSecret: "759568585e122274798c900839929486", //as long as this matches the settings "Account linking" on actions console it works
	}

	b.HandleExec(NewLight("1", "Testlampe"), func(dev gbridge.Device, req gbridge.CommandRequest, res *gbridge.CommandResponse) {
		log.Printf("DEBUG: Intent received.")
		log.Printf("Exec Cmd: %+v\n", req)
		res.Status = gbridge.CommandStatusSuccess
		res.States.Online = true
		res.States.On = req.Params.On
		log.Printf("Exec Res: %+v\n", res)
	})

	r.HandleFunc("/oauth", b.HandleOauth)
	r.HandleFunc("/token", b.HandleToken)
	r.HandleFunc("/smarthome", b.HandleSmartHome)
	log.Println("Listening:", addr)
	log.Println(http.ListenAndServe(addr, r))
}

func NewLight(id string, name string) gbridge.Device {
	d := gbridge.Device{
		Id:     id,
		Type:   gbridge.DeviceTypeLight,
		Traits: []gbridge.DeviceTrait{gbridge.DeviceTraitOnOff},
		Name: gbridge.DeviceName{
			DefaultNames: []string{name},
			Name:         name,
			Nicknames:    []string{name},
		},
	}
	return d
}

func NewSwitch(id string, name string) gbridge.Device {
	d := gbridge.Device{
		Id:     id,
		Type:   gbridge.DeviceTypeSwitch,
		Traits: []gbridge.DeviceTrait{gbridge.DeviceTraitOnOff},
		Name: gbridge.DeviceName{
			DefaultNames: []string{name},
			Name:         name,
			Nicknames:    []string{name},
		},
	}
	return d
}

Api key

This lib not use API key and Homegraph?

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.