Skip to content

Commit 263c086

Browse files
committed
[wip] adjust logging
1 parent 4d026f0 commit 263c086

File tree

3 files changed

+29
-35
lines changed

3 files changed

+29
-35
lines changed

tesla_ble_mqtt/CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
WARNING: broken for standalone deployment, stay on 0.0.6
88
OK for HA Addon
99

10-
- logging fix debug and adjustment
11-
- prevent always updating presence topic
12-
- prevent checking for presence if BLE_MAC is empty
10+
- logging adjustment and fix debug
1311

1412
## 0.0.7
1513

tesla_ble_mqtt/config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Tesla Local Commands"
2-
version: "0.0.7a"
2+
version: "0.0.7"
33
slug: "tesla_local_commands"
44
description: "Local BLE calls to control your Tesla."
55
# url: "tbc"
@@ -18,23 +18,23 @@ map:
1818
- share:rw
1919
startup: services
2020
options:
21+
vin: ""
22+
ble_mac: ""
23+
debug: false
2124
mqtt_ip: ""
2225
mqtt_port: "1883"
2326
mqtt_user: ""
2427
mqtt_pwd: ""
2528
send_cmd_retry_delay: "5"
26-
debug: false
27-
vin: ""
28-
ble_mac: ""
2929
schema:
30-
mqtt_ip: str
31-
mqtt_port: str
32-
mqtt_user: str
33-
mqtt_pwd: password
34-
send_cmd_retry_delay: int
30+
vin: str?
3531
debug: bool
36-
vin: str
37-
ble_mac: "str?"
32+
ble_mac: str?
33+
mqtt_ip: str?
34+
mqtt_port: str?
35+
mqtt_user: str?
36+
mqtt_pwd: password?
37+
send_cmd_retry_delay: str?
3838
# ingress: true
3939
# panel_icon: mdi:forward
4040
# backup_exclude:

tesla_ble_mqtt/rootfs/app/run.sh

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ if [ -n "${HASSIO_TOKEN:-}" ]; then
1414
DEBUG="$(bashio::config 'debug')"; export DEBUG
1515
fi
1616

17-
PRESENCE_BINARY_SENSOR=Unknown
18-
1917
# Set log level to debug
2018
bashio::config.true debug && bashio::log.level debug
2119

@@ -70,7 +68,6 @@ send_key() {
7068
break
7169
else
7270
bashio::log.error "tesla-control could not send the pubkey; make sure the car is awake and sufficiently close to the bluetooth device. Retrying in $SEND_CMD_RETRY_DELAY"
73-
bashio::log.error "Retrying in $SEND_CMD_RETRY_DELAY"
7471
sleep $SEND_CMD_RETRY_DELAY
7572
fi
7673
done
@@ -80,27 +77,26 @@ listen_to_ble() {
8077
PRESENCE_TIMEOUT=5
8178
bashio::log.info "Listening to BLE for presence"
8279
set +e
80+
if [ $? -eq 0 ]; then
81+
bashio::log.green "$BLE_MAC presence detected"
82+
mosquitto_pub --nodelay -h $MQTT_IP -p $MQTT_PORT -u "$MQTT_USER" -P "$MQTT_PWD" -t tesla_ble/bin
83+
ry_sensor/presence -m ON
84+
else
85+
bashio::log.yellow "$BLE_MAC presence not detected or issue in command, retrying now"
86+
mosquitto_pub --nodelay -h $MQTT_IP -p $MQTT_PORT -u "$MQTT_USER" -P "$MQTT_PWD" -t tesla_ble/bin
87+
ary_sensor/presence -m OFF
88+
fi
89+
8390
bluetoothctl --timeout $PRESENCE_TIMEOUT scan on | grep $BLE_MAC
8491
EXIT_STATUS=$?
8592
set -e
86-
if [ $? -eq 0 ]; then
87-
bashio::log.info "$BLE_MAC presence detected"
88-
if [[ $PRESENCE_BINARY_SENSOR == "OFF" || $PRESENCE_BINARY_SENSOR == "Unknown" ]]; then
89-
bashio::log.info "Updating topic tesla_ble/binary_sensor/presence ON"
90-
mosquitto_pub --nodelay -h $MQTT_IP -p $MQTT_PORT -u "$MQTT_USER" -P "$MQTT_PWD" -t tesla_ble/binary_sensor/presence -m ON
91-
PRESENCE_BINARY_SENSOR=ON
92-
else
93-
bashio::log.debug "Topic tesla_ble/binary_sensor/presence already ON"
94-
fi
95-
else
96-
bashio::log.warning "$BLE_MAC presence not detected or issue in command, will retry later"
97-
if [[ $PRESENCE_BINARY_SENSOR == "ON" || $PRESENCE_BINARY_SENSOR == "Unknown" ]]; then
98-
bashio::log.info "Updating topic tesla_ble/binary_sensor/presence OFF"
99-
mosquitto_pub --nodelay -h $MQTT_IP -p $MQTT_PORT -u "$MQTT_USER" -P "$MQTT_PWD" -t tesla_ble/binary_sensor/presence -m OFF
100-
PRESENCE_BINARY_SENSOR=OFF
101-
else
102-
bashio::log.debug "Topic tesla_ble/binary_sensor/presence already OFF"
103-
fi
93+
bashio::log.info "$BLE_MAC presence detected"
94+
mosquitto_pub --nodelay -h $MQTT_IP -p $MQTT_PORT -u "$MQTT_USER" -P "$MQTT_PWD" -t tesla_ble/binary_sensor/presence -m ON
95+
96+
bashio::log.warning "$BLE_MAC presence not detected or issue in command, will retry later"
97+
bashio::log.info "Updating topic tesla_ble/binary_sensor/presence OFF"
98+
mosquitto_pub --nodelay -h $MQTT_IP -p $MQTT_PORT -u "$MQTT_USER" -P "$MQTT_PWD" -t tesla_ble/binary_sensor/presence -m OFF
99+
bashio::log.debug "Topic tesla_ble/binary_sensor/presence already OFF"
104100
fi
105101
}
106102

0 commit comments

Comments
 (0)