Open lukyrys opened 1 month ago
Seems like either a bug in bluepy, or some other problem, maybe the heater firmware is buggy and sends response twice? "wr" response is expected, but should be returned in response to characteristic.write
:
Please try to reproduce the issue, maybe add print(response)
in line 163 in that file to check what's going on.
i mean that this caused by low signal on bluetooth. Before i have bt dongle 5m away now i run bridge on rpi4 cca 50cm behind heater and i have no problem. In bridge script is missing some fail restore, maybe restart after fail or sth like this..
If you used bundled docker-compose, docker should restart it automatically for you. Didn't it work or you expected something more elegant inside the script itself? I deliberately left such tricky cases to freely crash as proper BLE stack recovery would take too much work, but I encourage to PR your improvements, if you made some.
Sometimes script does not stop and gets stuck on backtrace and dont crash, so changing 'restart: always' in docker-compose.yaml won't work properly. In some debugging i added on vevor.py:164 try/catch with exit(0). There is no such problem on rpi but i have another problem with lost connection with mqtt (without any error but homeassistant has lost connection and script prints usual output with data from BLE) but BLE connection work further. This casue after few days work, maybe some problem with wifi signal. My ugly but functional solution for this is naming bridge service and adding subroutine 'vevor-restarter', which restarted docker each hour for sure.
version: '3.6'
services:
vevor-ble-bridge:
image: vevor-ble-bridge
container_name: vevor_bridge
network_mode: host
restart: always
cap_add:
- NET_ADMIN
- NET_RAW
environment:
BLE_MAC_ADDRESS: ${BLE_MAC_ADDRESS}
BLE_PASSKEY: ${BLE_PASSKEY}
DEVICE_NAME: ${DEVICE_NAME}
DEVICE_MANUFACTURER: ${DEVICE_MANUFACTURER}
DEVICE_MODEL: ${DEVICE_MODEL}
MQTT_HOST: ${MQTT_HOST}
MQTT_USERNAME: ${MQTT_USERNAME}
MQTT_PASSWORD: ${MQTT_PASSWORD}
MQTT_PREFIX: ${MQTT_PREFIX}
vevor-restarter:
image: docker
container_name: vevor_bridge_restarter
volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
command: ["/bin/sh", "-c", "while true; do sleep 3600; docker restart vevor_bridge; done"]
restart: unless-stopped
Now on rpi a have same problem :D with docker-compose above and dont crash