- Notifications
You must be signed in to change notification settings - Fork1
SDK to access Autogrow hardware and services programmatically
License
autogrow/go-jelly
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
SDK for Autogrow devices and associated integrations.
Traditionally agricultural providers utilise proprietary products and services which leave little flexibility for the growers to create their own solutions or connect them with existing infrastructure. This SDK is a work in progress and aims to provide customers with programmatic access to Autogrow devices.
Install as you would any go library:
go get github.com/AutogrowSystems/go-jelly
IntelliDoses and IntelliClimates are supported via the IntelliGrow API when used in conjuction with an IntelliLink.
import"github.com/AutogrowSystems/go-jelly/ig"user:="me"pass:="secret"client:=ig.NewClient(user,pass)devices,err:=client.Devices()iferr!=nil {panic(err)}// print the known devicesfor_,d:=rangedevices {fmt.Printf("%-12s %-18s %-20s %s",d.Type,d.ID,d.DeviceName,d.Growroom)}doser,err:=client.IntelliDose("ASLID17081149")iferr!=nil {panic(err)}fmt.Println("Water is currently %0.2f EC and %0.2f pH",doser.Metrics.Ec,doser.Metrics.PH)// Immediate push to the APIiferr:=doser.ForceIrrigation();err!=nil {panic(err)}// Push all the changes to the API at onceerr:= doser.Transaction(func()error) {doser.ForceIrrigation()// no errors returned in this modedoser.ForcePHDose()doser.ForceNutrientDose()returnnil})iferr!=nil {panic(err)}
You can also find a basic CLI client implementation incmd/ig.
Coming soon!
Currently the IntelliDose is supported when used in combination with thego-intelli gateway for event driven readings over the local network.
import"github.com/AutogrowSystems/go-jelly/sfc"// connect to the IntelliDose on the IntelliLinkidose:=sfc.NewIntelliDose(sn)err:=sfc.ConnectToNATS(idose,"nats://localhost:4222",10)iferr!=nil {panic(err)}for {// block until we get an updateidose.WaitForUpdate()// print out the readingsr:=idose.Readings()log.Printf("EC: %02.f pH: %02.f Temp: %0.2f",r.Ec,r.PH,r.NutTemp)}
You can see some usage examples in this repo:
- sfc/examples/daynightonoff.go: send a push notification when an IntelliDose transitions from day to night (or vice versa)
- sfc/examples/printreadings.go: print readings to the terminal every time they change