From 355a9a5c59ec6b0d5ffe2ab177ea0c783e2e4ea5 Mon Sep 17 00:00:00 2001 From: William Floyd Date: Mon, 20 Feb 2023 15:25:41 -0600 Subject: [PATCH] chore: Re-run helper and format text. --- devices/externaldevice/alarm_control_panel.go | 2 +- devices/externaldevice/binary_sensor.go | 2 +- devices/externaldevice/button.go | 2 +- devices/externaldevice/camera.go | 2 +- devices/externaldevice/climate.go | 2 +- devices/externaldevice/cover.go | 2 +- devices/externaldevice/device_tracker.go | 2 +- devices/externaldevice/fan.go | 2 +- devices/externaldevice/humidifier.go | 2 +- devices/externaldevice/light.go | 2 +- devices/externaldevice/lock.go | 2 +- devices/externaldevice/number.go | 2 +- devices/externaldevice/scene.go | 2 +- devices/externaldevice/select.go | 2 +- devices/externaldevice/sensor.go | 2 +- devices/externaldevice/siren.go | 2 +- devices/externaldevice/switch.go | 2 +- devices/externaldevice/text.go | 2 +- devices/externaldevice/update.go | 2 +- devices/externaldevice/vacuum.go | 2 +- go.mod | 5 ++- go.sum | 6 +++ main.go | 42 +++++++++---------- 23 files changed, 51 insertions(+), 42 deletions(-) diff --git a/devices/externaldevice/alarm_control_panel.go b/devices/externaldevice/alarm_control_panel.go index 656b6ba..32675bf 100644 --- a/devices/externaldevice/alarm_control_panel.go +++ b/devices/externaldevice/alarm_control_panel.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/binary_sensor.go b/devices/externaldevice/binary_sensor.go index e59bcb7..2fd4d2f 100644 --- a/devices/externaldevice/binary_sensor.go +++ b/devices/externaldevice/binary_sensor.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/button.go b/devices/externaldevice/button.go index 4636690..dae376c 100644 --- a/devices/externaldevice/button.go +++ b/devices/externaldevice/button.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/camera.go b/devices/externaldevice/camera.go index 2d9f4a0..7135fa2 100644 --- a/devices/externaldevice/camera.go +++ b/devices/externaldevice/camera.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/climate.go b/devices/externaldevice/climate.go index fe6c22b..962b2e4 100644 --- a/devices/externaldevice/climate.go +++ b/devices/externaldevice/climate.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/cover.go b/devices/externaldevice/cover.go index 0c538ca..0ae62f0 100644 --- a/devices/externaldevice/cover.go +++ b/devices/externaldevice/cover.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/device_tracker.go b/devices/externaldevice/device_tracker.go index b64da56..3b4aa55 100644 --- a/devices/externaldevice/device_tracker.go +++ b/devices/externaldevice/device_tracker.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/fan.go b/devices/externaldevice/fan.go index 388104f..38e4669 100644 --- a/devices/externaldevice/fan.go +++ b/devices/externaldevice/fan.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/humidifier.go b/devices/externaldevice/humidifier.go index a1146cd..7acda9b 100644 --- a/devices/externaldevice/humidifier.go +++ b/devices/externaldevice/humidifier.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/light.go b/devices/externaldevice/light.go index 3f5e347..e0f0c51 100644 --- a/devices/externaldevice/light.go +++ b/devices/externaldevice/light.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/lock.go b/devices/externaldevice/lock.go index be4bc1d..c657723 100644 --- a/devices/externaldevice/lock.go +++ b/devices/externaldevice/lock.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/number.go b/devices/externaldevice/number.go index 8690519..944af0a 100644 --- a/devices/externaldevice/number.go +++ b/devices/externaldevice/number.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/scene.go b/devices/externaldevice/scene.go index 911a114..42b6652 100644 --- a/devices/externaldevice/scene.go +++ b/devices/externaldevice/scene.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/select.go b/devices/externaldevice/select.go index 7bf291e..3dc1660 100644 --- a/devices/externaldevice/select.go +++ b/devices/externaldevice/select.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/sensor.go b/devices/externaldevice/sensor.go index 7172904..3db9daa 100644 --- a/devices/externaldevice/sensor.go +++ b/devices/externaldevice/sensor.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/siren.go b/devices/externaldevice/siren.go index 5c3fcb7..fae0e70 100644 --- a/devices/externaldevice/siren.go +++ b/devices/externaldevice/siren.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/switch.go b/devices/externaldevice/switch.go index 1829dc0..6f52948 100644 --- a/devices/externaldevice/switch.go +++ b/devices/externaldevice/switch.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/text.go b/devices/externaldevice/text.go index e265c77..7f0ebdc 100644 --- a/devices/externaldevice/text.go +++ b/devices/externaldevice/text.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "github.com/eclipse/paho.mqtt.golang" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/update.go b/devices/externaldevice/update.go index a2abe0f..d4fec0a 100644 --- a/devices/externaldevice/update.go +++ b/devices/externaldevice/update.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/devices/externaldevice/vacuum.go b/devices/externaldevice/vacuum.go index 1fdd26c..78221ec 100644 --- a/devices/externaldevice/vacuum.go +++ b/devices/externaldevice/vacuum.go @@ -4,10 +4,10 @@ import ( "encoding/json" common "github.com/W-Floyd/ha-mqtt-iot/common" store "github.com/W-Floyd/ha-mqtt-iot/store" - mqtt "tinygo.org/x/drivers/net/mqtt" strcase "github.com/iancoleman/strcase" "log" "time" + mqtt "tinygo.org/x/drivers/net/mqtt" ) // ////////////////////////////////////////////////////////////////////////////// diff --git a/go.mod b/go.mod index 999c456..cc86fea 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/Jeffail/gabs/v2 v2.6.1 github.com/dave/jennifer v1.5.0 github.com/denisbrodbeck/machineid v1.0.1 + github.com/eclipse/paho.mqtt.golang v1.4.2 github.com/ghodss/yaml v1.0.0 github.com/iancoleman/strcase v0.2.0 github.com/imdario/mergo v0.3.13 @@ -13,7 +14,9 @@ require ( ) require ( - github.com/eclipse/paho.mqtt.golang v1.4.2 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sync v0.1.0 // indirect golang.org/x/sys v0.5.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 695cc9d..c784356 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hajimehoshi/go-jisx0208 v1.0.0/go.mod h1:yYxEStHL7lt9uL+AbdWgW9gBumwieDoZCiB1f/0X0as= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= @@ -45,8 +47,12 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/main.go b/main.go index 81cbe45..25374fe 100644 --- a/main.go +++ b/main.go @@ -16,8 +16,8 @@ import ( "github.com/W-Floyd/ha-mqtt-iot/config" ExternalDevice "github.com/W-Floyd/ha-mqtt-iot/devices/externaldevice" "github.com/denisbrodbeck/machineid" - mqtt "tinygo.org/x/drivers/net/mqtt" "github.com/imdario/mergo" + mqtt "tinygo.org/x/drivers/net/mqtt" ) //go:generate go run ./helpers/ @@ -68,32 +68,32 @@ func main() { devices, opts := sconfig.Convert() -// if sconfig.Logging.Debug && sconfig.Logging.Mqtt { -// mqtt.DEBUG = common.DebugLog -// } -// if sconfig.Logging.Warn { -// mqtt.WARN = common.WarnLog -// } -// if sconfig.Logging.Error { -// mqtt.ERROR = common.ErrorLog -// } -// if sconfig.Logging.Critical { -// mqtt.CRITICAL = common.CriticalLog -// } + // if sconfig.Logging.Debug && sconfig.Logging.Mqtt { + // mqtt.DEBUG = common.DebugLog + // } + // if sconfig.Logging.Warn { + // mqtt.WARN = common.WarnLog + // } + // if sconfig.Logging.Error { + // mqtt.ERROR = common.ErrorLog + // } + // if sconfig.Logging.Critical { + // mqtt.CRITICAL = common.CriticalLog + // } common.LogState.Debug = sconfig.Logging.Debug common.LogState.Warn = sconfig.Logging.Warn common.LogState.Error = sconfig.Logging.Error common.LogState.Critical = sconfig.Logging.Critical -// opts.SetOnConnectHandler( -// func(c mqtt.Client) { -// for _, d := range devices { -// common.LogDebug("Connecting " + d.GetRawId() + "." + d.GetUniqueId()) -// go d.Subscribe() -// } -// }, -// ) + // opts.SetOnConnectHandler( + // func(c mqtt.Client) { + // for _, d := range devices { + // common.LogDebug("Connecting " + d.GetRawId() + "." + d.GetUniqueId()) + // go d.Subscribe() + // } + // }, + // ) client := mqtt.NewClient(opts)