Hi,
I have been successfully running your solution for quite some time with the flower sensors - thank you for developing this great solution.
However, for the last few days I have a strange problem.
The program runs flawless, once I have rebooted the RPi, when it runs a second time though it has problems with each and every single sensor. As it runs the first time well, I guess it does not have problems with the bluetooth interface, but also not with accessing the MQTT Server - as both work in the first run.
I am not quite sure what I am missing here and was wondering if you could have a look into this.
The log file looks as follows in the first run, when it works:
Tue, 25 May 2021 15:37:32 INFO PlantGateway version 0.7.0
Tue, 25 May 2021 15:37:32 INFO loaded config file from /home/pi/.plantgw.yaml
Tue, 25 May 2021 15:37:32 INFO Getting data from sensor liguster
Tue, 25 May 2021 15:37:32 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_battery/config
Tue, 25 May 2021 15:37:32 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_temperature/config
Tue, 25 May 2021 15:37:32 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_brightness/config
Tue, 25 May 2021 15:37:32 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_moisture/config
Tue, 25 May 2021 15:37:32 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_conductivity/config
Tue, 25 May 2021 15:37:32 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_timestamp/config
Tue, 25 May 2021 15:37:32 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:32 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:33 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:35 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:36 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:36 INFO sent data to topic miflora/liguster/
Tue, 25 May 2021 15:37:36 INFO Getting data from sensor szechuanpfeffer
Tue, 25 May 2021 15:37:36 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_battery/config
Tue, 25 May 2021 15:37:36 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_temperature/config
Tue, 25 May 2021 15:37:36 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_brightness/config
Tue, 25 May 2021 15:37:36 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_moisture/config
Tue, 25 May 2021 15:37:36 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_conductivity/config
Tue, 25 May 2021 15:37:36 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_timestamp/config
Tue, 25 May 2021 15:37:37 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:38 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:39 INFO MQTT connection returned result: Connection Accepted.
Tue, 25 May 2021 15:37:39 INFO sent data to topic miflora/szechuanpfeffer/
In the run later it looks like this:
Tue, 25 May 2021 16:47:10 INFO Getting data from sensor liguster
Tue, 25 May 2021 16:47:10 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_battery/config
Tue, 25 May 2021 16:47:10 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_temperature/config
Tue, 25 May 2021 16:47:10 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_brightness/config
Tue, 25 May 2021 16:47:10 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_moisture/config
Tue, 25 May 2021 16:47:10 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_conductivity/config
Tue, 25 May 2021 16:47:10 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA8963D3_timestamp/config
Tue, 25 May 2021 16:47:11 ERROR could not read data from 80:EA:CA:89:63:D3 (liguster) with reason:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/btlewrap/bluepy.py", line 27, in _func_wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/btlewrap/bluepy.py", line 56, in connect
self._peripheral = Peripheral(mac, iface=iface, addrType=self.address_type)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 391, in init
self._connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 439, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 80:EA:CA:89:63:D3, addr type: public
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all
self.process_mac(sensor)
File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 241, in process_mac
self._publish(sensor_config, poller)
File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 213, in _publish
MQTTAttributes.BATTERY.value: poller.parameter_value(MI_BATTERY),
File "/usr/local/lib/python3.7/dist-packages/miflora/miflora_poller.py", line 149, in parameter_value
return self.battery_level()
File "/usr/local/lib/python3.7/dist-packages/miflora/miflora_poller.py", line 119, in battery_level
self.firmware_version()
File "/usr/local/lib/python3.7/dist-packages/miflora/miflora_poller.py", line 127, in firmware_version
with self._bt_interface.connect(self._mac) as connection:
File "/usr/local/lib/python3.7/dist-packages/btlewrap/base.py", line 45, in enter
self._backend.connect(self._mac)
File "/usr/local/lib/python3.7/dist-packages/btlewrap/bluepy.py", line 33, in _func_wrapper
raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
Tue, 25 May 2021 16:47:11 INFO Getting data from sensor szechuanpfeffer
Tue, 25 May 2021 16:47:11 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_battery/config
Tue, 25 May 2021 16:47:11 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_temperature/config
Tue, 25 May 2021 16:47:11 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_brightness/config
Tue, 25 May 2021 16:47:11 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_moisture/config
Tue, 25 May 2021 16:47:11 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_conductivity/config
Tue, 25 May 2021 16:47:11 INFO sent sensor config to topic homeassistant/sensor/plant_80EACA895D11_timestamp/config
Tue, 25 May 2021 16:47:11 ERROR could not read data from 80:EA:CA:89:5D:11 (szechuanpfeffer) with reason:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/btlewrap/bluepy.py", line 27, in _func_wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/btlewrap/bluepy.py", line 56, in connect
self._peripheral = Peripheral(mac, iface=iface, addrType=self.address_type)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 391, in init
self._connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python3.7/dist-packages/bluepy/btle.py", line 439, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 80:EA:CA:89:5D:11, addr type: public
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 263, in process_all
self.process_mac(sensor)
File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 241, in process_mac
self._publish(sensor_config, poller)
File "/usr/local/lib/python3.7/dist-packages/plantgw/plantgw.py", line 213, in _publish
MQTTAttributes.BATTERY.value: poller.parameter_value(MI_BATTERY),
File "/usr/local/lib/python3.7/dist-packages/miflora/miflora_poller.py", line 149, in parameter_value
return self.battery_level()
File "/usr/local/lib/python3.7/dist-packages/miflora/miflora_poller.py", line 119, in battery_level
self.firmware_version()
File "/usr/local/lib/python3.7/dist-packages/miflora/miflora_poller.py", line 127, in firmware_version
with self._bt_interface.connect(self._mac) as connection:
File "/usr/local/lib/python3.7/dist-packages/btlewrap/base.py", line 45, in enter
self._backend.connect(self._mac)
File "/usr/local/lib/python3.7/dist-packages/btlewrap/bluepy.py", line 33, in _func_wrapper
raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
I am using a Raspberry Pi 3 Model B Plus Rev 1.3 with following hw configuration:
description: ARMv7 Processor rev 4 (v7l)
product: Raspberry Pi 3 Model B Plus Rev 1.3
serial: 00000000920415c0
width: 32 bits
capabilities: smp
*-core
description: Motherboard
physical id: 0
*-cpu:0
description: CPU
product: cpu
physical id: 0
bus info: cpu@0
size: 1400MHz
capacity: 1400MHz
capabilities: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 cpufreq
*-cpu:1
description: CPU
product: cpu
physical id: 1
bus info: cpu@1
size: 1400MHz
capacity: 1400MHz
capabilities: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 cpufreq
*-cpu:2
description: CPU
product: cpu
physical id: 2
bus info: cpu@2
size: 1400MHz
capacity: 1400MHz
capabilities: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 cpufreq
*-cpu:3
description: CPU
product: cpu
physical id: 3
bus info: cpu@3
size: 1400MHz
capacity: 1400MHz
capabilities: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 cpufreq
*-memory
description: System memory
physical id: 4
size: 924MiB
*-usbhost
product: DWC OTG Controller
vendor: Linux 5.10.17-v7+ dwc_otg_hcd
physical id: 1
bus info: usb@1
logical name: usb1
version: 5.10
capabilities: usb-2.00
configuration: driver=hub slots=1 speed=480Mbit/s
*-usb
description: USB hub
product: USB 2.0 Hub
vendor: Standard Microsystems Corp.
physical id: 1
bus info: usb@1:1
version: b.b3
capabilities: usb-2.00
configuration: driver=hub maxpower=2mA slots=4 speed=480Mbit/s
*-usb
description: USB hub
product: USB 2.0 Hub
vendor: Standard Microsystems Corp.
physical id: 1
bus info: usb@1:1.1
version: b.b3
capabilities: usb-2.00
configuration: driver=hub maxpower=2mA slots=3 speed=480Mbit/s
*-usb
description: Ethernet interface
vendor: Standard Microsystems Corp.
physical id: 1
bus info: usb@1:1.1.1
logical name: eth0
version: 3.00
serial: b8:27:eb:04:15:c0
capacity: 1Gbit/s
capabilities: usb-2.10 ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=lan78xx driverversion=5.10.17-v7+ link=no maxpower=2mA multicast=yes port=MII speed=480Mbit/s
*-network
description: Wireless interface
physical id: 2
logical name: wlan0
serial: b8:27:eb:51:40:95
capabilities: ethernet physical wireless
configuration: broadcast=yes driver=brcmfmac driverversion=7.45.229 firmware=01-2dbd9d2e ip=192.168.1.184 multicast=yes wireless=IEEE 802.11
OS: Linux 5.10.17-v7+ #1414 SMP Fri Apr 30 13:18:35 BST 2021 armv7l GNU/Linux
Any idea on what I am doing wrong is highly appreciated!
Thanks a lot!
Sven