Thanks for that suggestion!
The switch is bluetooth, so I’m guessing that this is the issue. My rPi and switch are about 2m apart though, so distance shouldn’t be a problem!
My logs get littered with these errors when it can’t connect:
Log Details (ERROR)
Tue Feb 05 2019 10:38:32 GMT+0000 (Greenwich Mean Time)
Failed to connect to switchmate
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/switchbot/__init__.py", line 48, in _sendpacket
hand.write(binascii.a2b_hex(key))
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 163, in write
return self.peripheral.writeCharacteristic(self.valHandle, val, withResponse)
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 502, in writeCharacteristic
return self._getResp('wr')
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 369, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 326, in _waitResp
raise BTLEException(BTLEException.DISCONNECTED, "Device disconnected")
bluepy.btle.BTLEException: Device disconnected
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/switchbot/__init__.py", line 36, in _connect
bluepy.btle.ADDR_TYPE_RANDOM)
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 353, in __init__
self._connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 402, in _connect
"Failed to connect to peripheral %s, addr type: %s" % (addr, addrType))
bluepy.btle.BTLEException: Failed to connect to peripheral FE:F9:C3:5F:8F:F6, addr type: random
also:
Log Details (ERROR)
Tue Feb 05 2019 10:43:00 GMT+0000 (Greenwich Mean Time)
Cannot connect to switchbot. Retrying
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/switchbot/__init__.py", line 48, in _sendpacket
hand.write(binascii.a2b_hex(key))
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 163, in write
return self.peripheral.writeCharacteristic(self.valHandle, val, withResponse)
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 502, in writeCharacteristic
return self._getResp('wr')
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 369, in _getResp
resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
File "/usr/local/lib/python3.6/site-packages/bluepy/btle.py", line 326, in _waitResp
raise BTLEException(BTLEException.DISCONNECTED, "Device disconnected")
bluepy.btle.BTLEException: Device disconnected