Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
splattner committed Jun 15, 2024
1 parent 82bb7d7 commit ba9dceb
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
vendor
__debug_bin
vdcd-bridge-amd64
vdcd-bridge-arm64
vdcd-bridge-arm64
.work
6 changes: 4 additions & 2 deletions pkg/discovery/deconz.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (e *DeconzDevice) websocketLoop() {
// Our main loop for the client
// We send our relevant packets here
log.Debugln("Deconz, Starting Deconz Websocket client main loop")
for {
for { // nolint:all
select {
case <-e.interrupt:
// We received a SIGINT (Ctrl + C). Terminate gracefully...
Expand Down Expand Up @@ -231,7 +231,7 @@ func (e *DeconzDevice) websocketReceiveHandler(connection *websocket.Conn) {
err = json.Unmarshal(msg, &message)

if err != nil {
log.Errorf("Unmarshal to DeconzWebSocketMessage failed\n", err.Error())
log.WithError(err).Error("Unmarshal to DeconzWebSocketMessage failed")
return
}

Expand Down Expand Up @@ -427,10 +427,12 @@ func (e *DeconzDevice) SetSaturation(saturation float32) {
func (e *DeconzDevice) setState() {

if e.IsLight {
log.Debug("Set Light state for")
//e.setLightState()
}

if e.IsGroup {
log.Debug("Set Group state for")
//e.setGroupState()
}
}
23 changes: 11 additions & 12 deletions pkg/discovery/deconz_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package discovery

import (
"fmt"
"strings"

deconzgroup "github.com/jurgen-kluft/go-conbee/groups"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -70,17 +69,17 @@ func (e *DeconzDevice) groupStateChangedCallback(state *DeconzState) {

}

func (e *DeconzDevice) setGroupState() {
// func (e *DeconzDevice) setGroupState() {

state := strings.Replace(e.group.Action.String(), "\n", ",", -1)
state = strings.Replace(state, " ", "", -1)
// state := strings.Replace(e.group.Action.String(), "\n", ",", -1)
// state = strings.Replace(state, " ", "", -1)

log.Infof("Deconz, call SetGroupState with state (%s) for Light with id %d\n", state, e.group.ID)
// log.Infof("Deconz, call SetGroupState with state (%s) for Light with id %d\n", state, e.group.ID)

conbeehost := fmt.Sprintf("%s:%d", e.deconzHost, e.deconzPort)
ll := deconzgroup.New(conbeehost, e.deconzAPI)
_, err := ll.SetGroupState(e.light.ID, e.group.Action)
if err != nil {
log.Debugln("Deconz, SetGroupState Error", err)
}
}
// conbeehost := fmt.Sprintf("%s:%d", e.deconzHost, e.deconzPort)
// ll := deconzgroup.New(conbeehost, e.deconzAPI)
// _, err := ll.SetGroupState(e.light.ID, e.group.Action)
// if err != nil {
// log.Debugln("Deconz, SetGroupState Error", err)
// }
// }
23 changes: 11 additions & 12 deletions pkg/discovery/deconz_light.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package discovery
import (
"fmt"
"math"
"strings"

deconzlight "github.com/jurgen-kluft/go-conbee/lights"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -96,17 +95,17 @@ func (e *DeconzDevice) lightStateChangedCallback(state *DeconzState) {

}

func (e *DeconzDevice) setLightState() {
// func (e *DeconzDevice) setLightState() {

state := strings.Replace(e.light.State.String(), "\n", ",", -1)
state = strings.Replace(state, " ", "", -1)
// state := strings.Replace(e.light.State.String(), "\n", ",", -1)
// state = strings.Replace(state, " ", "", -1)

log.Infof("Deconz, call SetLightState with state (%s) for Light with id %d\n", state, e.light.ID)
// log.Infof("Deconz, call SetLightState with state (%s) for Light with id %d\n", state, e.light.ID)

conbeehost := fmt.Sprintf("%s:%d", e.deconzHost, e.deconzPort)
ll := deconzlight.New(conbeehost, e.deconzAPI)
_, err := ll.SetLightState(e.light.ID, &e.light.State)
if err != nil {
log.Debugln("Deconz, SetLightState Error", err)
}
}
// conbeehost := fmt.Sprintf("%s:%d", e.deconzHost, e.deconzPort)
// ll := deconzlight.New(conbeehost, e.deconzAPI)
// _, err := ll.SetLightState(e.light.ID, &e.light.State)
// if err != nil {
// log.Debugln("Deconz, SetLightState Error", err)
// }
// }
2 changes: 1 addition & 1 deletion pkg/discovery/shelly.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (e *ShellyDevice) mqttDiscoverCallback() mqtt.MessageHandler {
shellyDevice := new(ShellyDevice)
err := json.Unmarshal(msg.Payload(), &shellyDevice)
if err != nil {
log.Errorf("Unmarshal to Shelly Device failed\n", err.Error())
log.WithError(err).Error("Unmarshal to Shelly Device failed")
return
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/discovery/tasmota.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (e *TasmotaDevice) mqttCallback() mqtt.MessageHandler {
var resultMesage TasmotaResultMsg
err := json.Unmarshal(msg.Payload(), &resultMesage)
if err != nil {
log.Errorf("Unmarshal to TasmotaPowerMsg failed\n", err.Error())
log.WithError(err).Error("Unmarshal to TasmotaPowerMsg failed")
return
}

Expand Down Expand Up @@ -226,7 +226,7 @@ func (e *TasmotaDevice) mqttCallback() mqtt.MessageHandler {
var teleMsg TasmotaTeleMsg
err := json.Unmarshal(msg.Payload(), &teleMsg)
if err != nil {
log.Errorf("Unmarshal to TasmotaTeleMsg failed\n", err.Error())
log.WithError(err).Error("Unmarshal to TasmotaTeleMsg failed")
return
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/vdcdapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,15 @@ func (e *Client) GetDeviceByTag(tag string) (*Device, error) {
return nil, errors.New(("Device not found"))
}

func (e *Client) getDeviceIndex(device Device) (*int, error) {
for i := 0; i < len(e.devices); i++ {
if e.devices[i].UniqueID == device.UniqueID {
return &i, nil
}
}

return nil, errors.New(("Device not found"))
}
// func (e *Client) getDeviceIndex(device Device) (*int, error) {
// for i := 0; i < len(e.devices); i++ {
// if e.devices[i].UniqueID == device.UniqueID {
// return &i, nil
// }
// }

// return nil, errors.New(("Device not found"))
// }

// Send a channel message to the vdcd for the given ChannelName and ChannelType
func (e *Client) UpdateValue(device *Device, channelName string, channelType ChannelTypeType) {
Expand Down
20 changes: 10 additions & 10 deletions pkg/vdcdapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ const (

const (
LightOutput OutputType = "light"
ColorLightOutput = "colorlight"
CtLightOutput = "ctlight"
MovingLightOutput = "movinglight"
HeatingValveOutput = "heatingvalve"
VentilationOutput = "ventilation"
FanCoilUnitOutput = "fancoilunit"
ShadowOutput = "shadow"
ActionOutput = "action"
BasicOutput = "basic"
ColorLightOutput OutputType = "colorlight"
CtLightOutput OutputType = "ctlight"
MovingLightOutput OutputType = "movinglight"
HeatingValveOutput OutputType = "heatingvalve"
VentilationOutput OutputType = "ventilation"
FanCoilUnitOutput OutputType = "fancoilunit"
ShadowOutput OutputType = "shadow"
ActionOutput OutputType = "action"
BasicOutput OutputType = "basic"
)

const (
Expand Down Expand Up @@ -293,7 +293,7 @@ type Device struct {
Events map[string]Event `json:"events,omitempty"`
Properties map[string]Property `json:"properties,omitempty"`

value float32 `json:"-"`
//value float32 `json:"-"`
client *Client `json:"-"`
channel_cb func(message *GenericVDCDMessage, device *Device) `json:"-"`
InitDone bool `json:"-"`
Expand Down

0 comments on commit ba9dceb

Please sign in to comment.