Skip to content

Commit 6185b81

Browse files
committed
Reworked values in control pilot topic and split it up
1 parent 4e196e4 commit 6185b81

File tree

6 files changed

+105
-64
lines changed

6 files changed

+105
-64
lines changed

README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,19 @@ chargers:
2727
- name: wallboxpulsarcharger
2828
type: custom
2929
status:
30-
source: combined
31-
# not plugged & not charging -> Status A
32-
plugged: # -> Status B
33-
source: mqtt
34-
topic: wallbox_<your_wallbox_id>/cable_connected/state
35-
charging: # -> Status C
36-
source: mqtt
37-
topic: wallbox_<your_wallbox_id>/charging_power/state
38-
jq: "if . > 0 then 1 else 0 end"
30+
source: mqtt
31+
topic: wallbox_147293/control_pilot/state
3932
enabled: # charger enabled state (true/false or 0/1)
4033
source: mqtt
41-
topic: wallbox_<your_wallbox_id>/charging_enable/state
42-
timeout: 120m
34+
topic: wallbox_147293/charging_enable/state
4335
enable: # set charger enabled state (true/false or 0/1)
4436
source: mqtt
45-
topic: wallbox_<your_wallbox_id>/charging_enable/set
37+
topic: wallbox_147293/charging_enable/set
4638
payload: ${enable:%d}
4739
maxcurrent: # set charger max current (A)
4840
source: mqtt
49-
topic: wallbox_<your_wallbox_id>/max_charging_current/set
41+
topic: wallbox_147293/max_charging_current/set
42+
5043

5144
loadpoints:
5245
- title: wallboxpulsar
@@ -87,7 +80,7 @@ Note: Doesn't work with firmware v6.6.x see issue https://github.com/jagheterfre
8780
3. `ssh` to your Wallbox and run
8881

8982
```sh
90-
curl -sSfL https://github.com/sweber/wallbox-mqtt-bridge/releases/tag/v20241028_1/install.sh > install.sh && bash install.sh
83+
curl -sSfL https://github.com/sweber/wallbox-mqtt-bridge/releases/tag/v20241029_1/install.sh > install.sh && bash install.sh
9184
```
9285

9386
Note: To upgrade to new version, simply run the command from step 3 again.

app/sensors.go

+45-31
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ func getEntities(w *wallbox.Wallbox) map[string]Entity {
172172
"suggested_display_precision": "1",
173173
},
174174
},
175+
"control_pilot": {
176+
Component: "sensor",
177+
Getter: func() string { return wallbox.ControlPilotStates[w.Data.RedisState.ControlPilot].Status },
178+
Config: map[string]string{
179+
"name": "Control pilot",
180+
},
181+
},
175182
"cumulative_added_energy": {
176183
Component: "sensor",
177184
Getter: func() string { return fmt.Sprint(w.Data.SQL.CumulativeAddedEnergy) },
@@ -231,38 +238,38 @@ func getEntities(w *wallbox.Wallbox) map[string]Entity {
231238
},
232239
},
233240
"temp_l1": {
234-
Component: "sensor",
235-
Getter: func() string { return fmt.Sprint(w.Data.RedisM2W.TempL1) },
236-
Config: map[string]string{
237-
"name": "Temperature Line 1",
238-
"unit_of_measurement": "°C",
239-
"device_class": "temperature",
240-
"state_class": "measurement",
241-
"suggested_display_precision": "1",
242-
},
241+
Component: "sensor",
242+
Getter: func() string { return fmt.Sprint(w.Data.RedisM2W.TempL1) },
243+
Config: map[string]string{
244+
"name": "Temperature Line 1",
245+
"unit_of_measurement": "°C",
246+
"device_class": "temperature",
247+
"state_class": "measurement",
248+
"suggested_display_precision": "1",
249+
},
243250
},
244251
"temp_l2": {
245-
Component: "sensor",
246-
Getter: func() string { return fmt.Sprint(w.Data.RedisM2W.TempL2) },
247-
Config: map[string]string{
248-
"name": "Temperature Line 2",
249-
"unit_of_measurement": "°C",
250-
"device_class": "temperature",
251-
"state_class": "measurement",
252-
"suggested_display_precision": "1",
253-
},
252+
Component: "sensor",
253+
Getter: func() string { return fmt.Sprint(w.Data.RedisM2W.TempL2) },
254+
Config: map[string]string{
255+
"name": "Temperature Line 2",
256+
"unit_of_measurement": "°C",
257+
"device_class": "temperature",
258+
"state_class": "measurement",
259+
"suggested_display_precision": "1",
260+
},
254261
},
255262
"temp_l3": {
256-
Component: "sensor",
257-
Getter: func() string { return fmt.Sprint(w.Data.RedisM2W.TempL3) },
258-
Config: map[string]string{
259-
"name": "Temperature Line 3",
260-
"unit_of_measurement": "°C",
261-
"device_class": "temperature",
262-
"state_class": "measurement",
263-
"suggested_display_precision": "1",
264-
},
265-
},
263+
Component: "sensor",
264+
Getter: func() string { return fmt.Sprint(w.Data.RedisM2W.TempL3) },
265+
Config: map[string]string{
266+
"name": "Temperature Line 3",
267+
"unit_of_measurement": "°C",
268+
"device_class": "temperature",
269+
"state_class": "measurement",
270+
"suggested_display_precision": "1",
271+
},
272+
},
266273
}
267274
}
268275

@@ -368,11 +375,18 @@ func getPowerBoostEntities(w *wallbox.Wallbox, c *WallboxConfig) map[string]Enti
368375

369376
func getDebugEntities(w *wallbox.Wallbox) map[string]Entity {
370377
return map[string]Entity{
371-
"control_pilot": {
378+
"control_pilot_detail": {
372379
Component: "sensor",
373-
Getter: w.ControlPilotStatus,
380+
Getter: func() string { return wallbox.ControlPilotStates[w.Data.RedisState.ControlPilot].Detail },
374381
Config: map[string]string{
375-
"name": "Control pilot",
382+
"name": "Control pilot detail",
383+
},
384+
},
385+
"control_pilot_detail_message": {
386+
Component: "sensor",
387+
Getter: func() string { return wallbox.ControlPilotStates[w.Data.RedisState.ControlPilot].Message },
388+
Config: map[string]string{
389+
"name": "Control pilot detail message",
376390
},
377391
},
378392
"m2w_status": {

app/tui.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func RunTuiSetup() {
4949
config.Settings.DebugSensors = false
5050
config.Settings.PowerBoostEnabled = false
5151
config.Settings.VerboseOutput = false
52-
config.Settings.IntervalUpdatedTopics = []string{"charging_enable", "charging_power"}
52+
config.Settings.IntervalUpdatedTopics = []string{"charging_enable", "charging_power", "control_pilot"}
5353
config.Settings.IntervalUpdatedTopicsSeconds = 15
5454

5555
askConfirmOrNew(&config.MQTT.Host, "MQTT Host")

app/wallbox/wallbox.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ type DataCache struct {
4343
PowerBoostLine2Current float64 `redis:"PBO.line2.current.value"`
4444
PowerBoostLine3Current float64 `redis:"PBO.line3.current.value"`
4545
PowerBoostCumulativeEnergy float64 `redis:"PBO.energy_wh.value"`
46-
TempL1 float64 `redis:"tms.line1.temp_deg.value"`
47-
TempL2 float64 `redis:"tms.line2.temp_deg.value"`
48-
TempL3 float64 `redis:"tms.line3.temp_deg.value"`
46+
TempL1 float64 `redis:"tms.line1.temp_deg.value"`
47+
TempL2 float64 `redis:"tms.line2.temp_deg.value"`
48+
TempL3 float64 `redis:"tms.line3.temp_deg.value"`
4949
}
5050
}
5151

@@ -209,10 +209,6 @@ func (w *Wallbox) EffectiveStatus() string {
209209
return wallboxStatusCodes[tmsStatus]
210210
}
211211

212-
func (w *Wallbox) ControlPilotStatus() string {
213-
return fmt.Sprintf("%d: %s", w.Data.RedisState.ControlPilot, controlPilotStates[w.Data.RedisState.ControlPilot])
214-
}
215-
216212
func (w *Wallbox) StateMachineState() string {
217213
return fmt.Sprintf("%d: %s", w.Data.RedisState.SessionState, stateMachineStates[w.Data.RedisState.SessionState])
218214
}

app/wallbox/wallbox_const.go

+47-9
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,51 @@ var stateMachineStates = map[int]string{
7979
0xD2: "Wait Unlock",
8080
}
8181

82-
var controlPilotStates = map[int]string{
83-
0xE: "Error",
84-
0xF: "Failure",
85-
0xA1: "Ready 1", // S1 at 12V, car not connected
86-
0xA2: "Ready 2",
87-
0xB1: "Connected 1", // S1 at 9V, car connected not allowed charge
88-
0xB2: "Connected 2", // S1 at Oscillator, car connected allowed charge
89-
0xC1: "Charging 1",
90-
0xC2: "Charging 2", // S2 closed
82+
type ControlPilotState struct {
83+
Status string
84+
Detail string
85+
Message string
86+
}
87+
88+
var ControlPilotStates = map[int]ControlPilotState{
89+
0xE: {
90+
Status: "E",
91+
Detail: "E",
92+
Message: "Error",
93+
},
94+
0xF: {
95+
Status: "F",
96+
Detail: "F",
97+
Message: "Failure",
98+
},
99+
0xA1: {
100+
Status: "A",
101+
Detail: "A1",
102+
Message: "Ready (S1 at 12V, car not connected)", // S1 at 12V, car not connected
103+
},
104+
0xA2: {
105+
Status: "A",
106+
Detail: "A2",
107+
Message: "Ready",
108+
},
109+
0xB1: {
110+
Status: "B",
111+
Detail: "B1",
112+
Message: "Connected (S1 at 9V, car connected not allowed charge)", // S1 at 9V, car connected not allowed charge
113+
},
114+
0xB2: {
115+
Status: "B",
116+
Detail: "B2",
117+
Message: "Connected (S1 at Oscillator, car connected allowed charge)", // S1 at Oscillator, car connected allowed charge
118+
},
119+
0xC1: {
120+
Status: "C",
121+
Detail: "C1",
122+
Message: "Charging",
123+
},
124+
0xC2: {
125+
Status: "C",
126+
Detail: "C2",
127+
Message: "Charging (S2 closed))", // S2 closed
128+
},
91129
}

install.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ find ~/mqtt-bridge/ -type f ! -name bridge.ini -delete
1010
echo "Downloading the bridge"
1111
arch=$(uname -m)
1212
if [ "$arch" == "armv7l" ]; then
13-
curl -sSfL --create-dirs -o ~/mqtt-bridge/bridge https://github.com/sweber/wallbox-mqtt-bridge/releases/download/v20241028_1/bridge-armhf
13+
curl -sSfL --create-dirs -o ~/mqtt-bridge/bridge https://github.com/sweber/wallbox-mqtt-bridge/releases/download/v20241029_1/bridge-armhf
1414
elif [ "$arch" == "aarch64" ]; then
15-
curl -sSfL --create-dirs -o ~/mqtt-bridge/bridge https://github.com/sweber/wallbox-mqtt-bridge/releases/download/v20241028_1/bridge-arm64
15+
curl -sSfL --create-dirs -o ~/mqtt-bridge/bridge https://github.com/sweber/wallbox-mqtt-bridge/releases/download/v20241029_1/bridge-arm64
1616
else
1717
echo "Unknown architecture $arch"
1818
exit 1

0 commit comments

Comments
 (0)