Closed ACrazyConcept closed 5 years ago
What guidance do you need? This should still work. Although I have some improvements and notes yet unpublished.
To begin with just how to run it :) When I execute run.py:
$ sudo python3 run.py Traceback (most recent call last): File "run.py", line 27, in <module> fan = Calima("58:2B:DB:01:D5:33", "04243571") File "/home/homeassistant/.homeassistant/pycalima/pycalima/Calima.py", line 51, in __init__ self.conn = ble.Peripheral(deviceAddr=addr) File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 391, in __init__ self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.5/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 58:2B:DB:01:D5:33, addr type: public Exception ignored in: <bound method Calima.__del__ of <pycalima.Calima.Calima object at 0x76a0f890>> Traceback (most recent call last): File "/home/homeassistant/.homeassistant/pycalima/pycalima/Calima.py", line 55, in __del__ self.conn.disconnect() AttributeError: 'Calima' object has no attribute 'conn'
btw. I am hoping to use it with home assistant: https://community.home-assistant.io/t/pax-calima/118489/4
The error is a bit hidden in the trace. The interesting redout from your error is bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 58:2B:DB:01:D5:33
Does running
sudo python3 cmdline.py -m 58:2B:DB:01:D5:33 -p "04243571"
work reliably for you?
As for hassio integration. I don't run hassio myself, but it shouldn't be to hard creating a custom component as described here. Especially look at the example sensor. From there you would include pycalima and use the getters to fill the entity state.
Eg in the update function,
fan = Calima("Mac","pin")
self._state = fan.getState()
It's probably a bit more than this, but it should be the essence of it.
Wrong button...
That gives me:
$ sudo python3 cmdline.py -m 58:2B:DB:01:D5:33 -p "04243571" Traceback (most recent call last): File "cmdline.py", line 134, in <module> main() File "cmdline.py", line 80, in main fan = Calima(mac_address, pincode) File "/home/homeassistant/.homeassistant/pycalima/pycalima/Calima.py", line 51, in __init__ self.conn = ble.Peripheral(deviceAddr=addr) File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 391, in __init__ self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.5/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 58:2B:DB:01:D5:33, addr type: public Exception ignored in: <bound method Calima.__del__ of <pycalima.Calima.Calima object at 0x76a3b370>> Traceback (most recent call last): File "/home/homeassistant/.homeassistant/pycalima/pycalima/Calima.py", line 55, in __del__ self.conn.disconnect() AttributeError: 'Calima' object has no attribute 'conn'
Do I need to somehow reset the fan if I had connected it to my phone previously?
What platform are you using? Can you see the fan using sudo hcitool lescan
?
Edit: I think I got the idea now. Seems to be woking except those two functions.
Ok back to this project:
I now have something working.
running:
sudo python3 cmdline.py -m 58:2B:DB:01:D5:33 -p "04243571"
gives me most of the return values except for two:
Device Name: PAX Calima Model Number: 10 Serial Number: 0000000 Hardware Revision: 01.00 Firmware Revision: 01.03 Software Revision: 01.05 Manufacturer: PAX Alias: Pax Traceback (most recent call last): File "cmdline.py", line 134, in <module> main() File "cmdline.py", line 110, in main print("Factory Settings Changed: ", fan.getFactorySettingsChanged()) File "/pycalima/pycalima/Calima.py", line 174, in getFactorySettingsChanged return bool(unpack('<I', self._readUUID(CHARACTERISTIC_FACTORY_SETTINGS_CHANGED))) struct.error: unpack requires a buffer of 4 bytes
outcommenting
print("Factory Settings Changed: ", fan.getFactorySettingsChanged())
it moves on to:
Device Name: PAX Calima Model Number: 10 Serial Number: 0000000 Hardware Revision: 01.00 Firmware Revision: 01.03 Software Revision: 01.05 Manufacturer: PAX Alias: Pax Traceback (most recent call last): File "cmdline.py", line 134, in <module> main() File "cmdline.py", line 111, in main print("Mode: ", fan.getMode()) File "/pycalima/pycalima/Calima.py", line 177, in getMode v = unpack('<H', self._readUUID(CHARACTERISTIC_MODE)) struct.error: unpack requires a buffer of 2 bytes
outcommenting
print("Mode: ", fan.getMode())
as well gets me to the end of the script:
Device Name: PAX Calima Model Number: 10 Serial Number: 0000000 Hardware Revision: 01.00 Firmware Revision: 01.03 Software Revision: 01.05 Manufacturer: PAX Alias: Pax Fan Speed Settings: Fanspeeds(Humidity=2250, Light=975, Trickle=975) Sensors Sensitivity: Sensitivity(HumidityOn=1, Humidity=2, LightOn=0, Light=2) Light Sensor Settings: LightSensorSettings(DelayedStart=0, RunningTime=5) Heat Distributor: HeatDistributorSettings(TemperatureLimit=25, FanSpeedBelow=0, FanSpeedAbove=2100) Boost Mode: BoostMode(OnOff=0, Speed=0, Seconds=0) Led: 0000 Automatic Cycles: 0 Time: Time(DayOfWeek=6, Hour=11, Minute=7, Second=22) Silent Hours: SilentHours(On=1, StartingHour=22, StartingMinute=0, EndingHour=6, EndingMinute=0) Trickle Days: TrickleDays(Weekdays=1, Weekends=1) FanState(Humidity=53, Temp=26.75, Light=30, RPM=968, Mode='Trickle ventilation') FanState(Humidity=53, Temp=26.75, Light=30, RPM=967, Mode='Trickle ventilation') FanState(Humidity=53, Temp=26.75, Light=30, RPM=964, Mode='Trickle ventilation') FanState(Humidity=53, Temp=26.75, Light=30, RPM=963, Mode='Trickle ventilation') FanState(Humidity=53, Temp=26.75, Light=30, RPM=960, Mode='Trickle ventilation')
Looks like the characteristics have different lengths. Do you mind running the command below and paste the output?
sudo python3 cmdline.py -m your_mac -p "your_pin" -s
Disregard that. It's staring me right in the eyes. I will try and patch it soon!
Awesome thanks. Btw I was running on a RPI 3B+, now moved to a RPI Zero W.
The patch seemed to work. Now get this from the cmdline:
Device Name: PAX Calima Model Number: 10 Serial Number: 0000000 Hardware Revision: 01.00 Firmware Revision: 01.03 Software Revision: 01.05 Manufacturer: PAX Alias: Ventilatoren Factory Settings Changed: (True,) Mode: None Fan Speed Settings: Fanspeeds(Humidity=0, Light=0, Trickle=0) Sensors Sensitivity: Sensitivity(HumidityOn=0, Humidity=2, LightOn=0, Light=2) Light Sensor Settings: LightSensorSettings(DelayedStart=0, RunningTime=5) Heat Distributor: HeatDistributorSettings(TemperatureLimit=25, FanSpeedBelow=0, FanSpeedAbove=2100) Boost Mode: BoostMode(OnOff=0, Speed=2400, Seconds=0) Led: 0000 Automatic Cycles: 0 Time: Time(DayOfWeek=3, Hour=20, Minute=6, Second=11) Silent Hours: SilentHours(On=1, StartingHour=22, StartingMinute=0, EndingHour=6, EndingMinute=0) Trickle Days: TrickleDays(Weekdays=0, Weekends=0) FanState(Humidity=234, Temp=26.5, Light=7, RPM=0, Mode='Trickle ventilation')
Is anyone using this? Would like som guidance of how to make it work.