Skip to content

Commit

Permalink
add workaround for copper sb locking
Browse files Browse the repository at this point in the history
  • Loading branch information
jagheterfredrik committed Dec 25, 2023
1 parent d79bc90 commit 9eebe99
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/wallbox/wallbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Wallbox struct {
redisClient *redis.Client
sqlClient *sqlx.DB
Data DataCache
ChargerType string `db:"charger_type"`
}

func New() *Wallbox {
Expand All @@ -51,6 +52,9 @@ func New() *Wallbox {
panic(err)
}

query := "select SUBSTRING_INDEX(part_number, '-', 1) AS charger_type from charger_info;"
w.sqlClient.Get(&w, query)

w.redisClient = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
Expand Down Expand Up @@ -144,7 +148,9 @@ func (w *Wallbox) SetLocked(lock int) {
if lock == w.Data.SQL.Lock {
return
}
if lock == 1 {
if w.ChargerType == "CPB1" {
w.sqlClient.MustExec("UPDATE `wallbox_config` SET `lock`=?", lock)
} else if lock == 1 {
sendToPosixQueue("WALLBOX_MYWALLBOX_WALLBOX_LOGIN", "EVENT_REQUEST_LOCK")
} else {
userId := w.UserId()
Expand Down

0 comments on commit 9eebe99

Please sign in to comment.