Pax Calima

Would be great to have suppport for Pax Calima bathroom fan. Its controlled over bluetooth. There is a python interface here https://github.com/PatrickE94/pycalima

I’m with you. I already have the fan installed. Have you been using pycalima on its own?

I have tried but haven´t been able to get it running. Haven´t had the time to troubleshoot it.
But a component in hass would be better :slight_smile:

Same. Wish I had the competency to do it myself. I just don’t know where to start.

I managed to get the python interface working except two functions which I probable won’t need anyway.

Hi @Sand, mind sharing how you use this pyhton interface? Are you running hass.io? Are you using command line sensor?

I too would like to have some sort of add-on for Pax Calima on hass.io. My coding skills are at ''hello world" level :smile:

Hi @Zetor77,

I am running a Pi Zero W with Hassbian for controlling the Calima.
So I have just put PatrickE94’s interface into a folder and then created a couple of scripts I can call with the command line sensor. I then control in Node-Red via homeassistant.update_entity service, based on various rules.

I am also pretty new to python so it can probably be done a lot nicer.

In this example I am first setting the boost mode to On, 1000RPM, 600 seconds, and then giving it some time to update its state before I return the new state and boost mode to the sensor.

from pycalima.Calima import Calima
import sys
import time
start_time = time.time()

fan = Calima("MA:CC:AD:DR:ES:SS", "012345")

fan.setBoostMode(1, 1000 , 600)
time.sleep(5)
print(fan.getState())
print(fan.getBoostMode())

fan.disconnect()
print("--- %s seconds ---" % (time.time() - start_time))

configuration.yaml:

- platform: command_line
    name: fan_setboost_1000_and_getstate
    command: "python3 /home/homeassistant/.homeassistant/pycalima/calima_set_boost_mode_on_1000_and_get_state.py"
    value_template: '{{ value }}'
    scan_interval: 30000000
    command_timeout: 30

Output:

FanState(Humidity=12, Temp=23.75, Light=2, RPM=1211, Mode='Boost')
BoostMode(OnOff=1, Speed=1000, Seconds=590)
--- 19.512956142425537 seconds ---
1 Like

Does anybody know if there a possibility to run such code of PatrickE94 under an ESP32 board?

Many thanks.

@Sand
well, I cannot get this to work at all. The script is just timing out and sensor is not updated. My phone can connect to the fan without issues even if it is located behind a wall. Any tips you might suggest what am i doing wrong? Or is it just poor BT of my Pi 3 b+? I have double checked that my MAC and PIN are correct. I have tested with another python script, that the command line sensor itself is working fine.

Hard to say. Can you run the script from the console?

Nope, cannot run script from the console.

Okay, well still difficult to guess without some more info on the setup, script and observed behavior when you run the script.

My config setup is like this:
image

So I use one for just reading sensor values, one for setting the fan speed in boost mode, and one to turn it off if necessary.

To get the state PatrickE94 suggested an alternative not requiring pin code. I just added the script timing.

import bluepy.btle as ble
from struct import unpack, pack
import time
start_time = time.time()

addr = "58:2B:DB:01:D5:33"

fan = ble.Peripheral(deviceAddr=addr)

state_c = fan.getCharacteristics(uuid="528b80e8-c47a-4c0a-bdf1-916a7748f412")[0]
try:
    v = unpack('<4HBHB', state_c.read())
    print(v)
except Exception as e:
    print(e)

fan.disconnect()
print("--- %s seconds ---" % (time.time() - start_time))

Set boost mode is still the same, just using a parameter for the speed:

from pycalima.Calima import Calima
import sys
Connected = False #global variable for the state of the connection

fan = Calima("58:2B:DB:01:D5:33", "04243571")

fan.setBoostMode(1, int(float(sys.argv[1])), 600)

print(sys.argv[1])
fan.disconnect()

Thanks for sharing your Calima setup. I finally got it working… sort of. I think my Ruuvitag BLE beacon add-on was interfering with connection to Calima fan. As soon as I stopped Ruuvitag add-on, my command line sensor got values from python script. The problem now is that I cannot use Ruuvitag add-on if I want to control Calima fan. And my log is bloated with errors. Here’s my setup.

Huomautus 2020-04-05 193911

sensors.yaml

  - platform: command_line
    name: fan_getstate
    command: "python3 /config/pycalima/calima_get_state.py"
    value_template: '{{ value }}'
    scan_interval: 60
    command_timeout: 55

Huomautus 2020-04-05 193912

I got some really good initial results from using pygatt instead of bluepy.

image

Hi all,
So I’ve recently moved all my servers and homelab stuff into a storage room, my plan was originally to use 2 vents in each end of the room for airflow, but it would seem this is not going to be enough. I was thinking of getting a floorstanding AC with the waste heat going out one of the vents, but these are not really that effective and quite expensive, and I came across the Pax Calima fan thingy.
I have a hassio running on an rpi3 and was wondering if it’s possible with this pygatt to have hassio automatically start the fan when a treshold temperature has been met ? Are there also any temperature measuring devices or one I could build which uses the gpio of the rpi? Or maybe have the servers report their temperature ? Servers are running Unraid (based on slack).
I’m a bit of a newbie when it comes to python and programming in general so any pointers would be most appreciated.

It seems pycalima has some installation errors.

#Get the latest to your directory
wget https://github.com/PatrickE94/pycalima/archive/master.zip
unzip master.zip
cd pycalima-master

#Install as python package
# cmdline.py is in wrong directory, move it
mv cmdline.py pycalima
pip3 install . 
# README.rst mentions run.py but this version does not have it. Check it from other forks

# now calima cmdline works
calima -h

First version of Pax Calima component, only reads values.
PaxCalima
5 Likes

I’m very new in Home assistant but I have got the Pax Calima working on a Raspberry zero W an I have a Home assistant server running on another Raspberry pi 4. I have connected both of my Pax fans on the zero but how can I send a “boost”-command from my Home assistant (on another device)?
The thing is that I want to att a wireless button (from IKEA) to make the fan boost when I press it. I have all y other config in the HA but it’s too far away from the Pax fans so I have them connected to I Zero…

I solved this exact dilemma with node-red on the Zero listening to MQTT messages from HA.

1 Like

Great! I’ve installed Node-red now but I’m kinda stuck there. How do I build a script (?) listening on MQTT and how do I send a MQTT-command from HA?