Pax Calima bluetooth controlled fan
Posted: Saturday 23 June 2018 17:59
Hi,
I have installed pycalima, which is a python interface to control Pax Calima fan.
As I am not very experienced in Python, I thought I could at least show how to read the values from Calima into Domoticz and if someone has the knowledge of how to write to the fan using virtual dimmer, I would be very happy. I have tried different methods, but it has failed, probably due to the fact(?) that domoticz is running another instance of python, so any libraries that I install is not seen, but it might be for other reasons.
The installation of pycalima was not completely straightforward for me, but I managed to get it to work after installing some extra libraries.
You have to add 4 virtual sensors, Temp/Humidity, Lux, Percentage and Waterflow sensor. The Waterflow (airflow) is scaled as l/s to more easily compare with the Pax app which shows the value in l/s. Further more, the Humidity sensor goes to 0 when the humidity is normalized, so I assume that it is an offset of the normal humidity level (but uncertain if it is additive or multiplicative offset). I have also scaled the percentage to flow as a simple linear function. Looking at the data, it seems to be somewhat quadratic, but the error is relatively small.
Here is the code that runs on cron every 5:th minute. Remove some of the hashtags to get debug information. I assume that there is smarter ways to parse the data, so feel free to give some hints
I have installed pycalima, which is a python interface to control Pax Calima fan.
As I am not very experienced in Python, I thought I could at least show how to read the values from Calima into Domoticz and if someone has the knowledge of how to write to the fan using virtual dimmer, I would be very happy. I have tried different methods, but it has failed, probably due to the fact(?) that domoticz is running another instance of python, so any libraries that I install is not seen, but it might be for other reasons.
The installation of pycalima was not completely straightforward for me, but I managed to get it to work after installing some extra libraries.
You have to add 4 virtual sensors, Temp/Humidity, Lux, Percentage and Waterflow sensor. The Waterflow (airflow) is scaled as l/s to more easily compare with the Pax app which shows the value in l/s. Further more, the Humidity sensor goes to 0 when the humidity is normalized, so I assume that it is an offset of the normal humidity level (but uncertain if it is additive or multiplicative offset). I have also scaled the percentage to flow as a simple linear function. Looking at the data, it seems to be somewhat quadratic, but the error is relatively small.
Here is the code that runs on cron every 5:th minute. Remove some of the hashtags to get debug information. I assume that there is smarter ways to parse the data, so feel free to give some hints
Code: Select all
from Calima import Calima
import json
import requests
CALIMA_MAC = "xx:xx:xx:xx:xx:xx"
CALIMA_ID = "12345678"
fan = Calima(CALIMA_MAC, CALIMA_ID)
state = str(fan.getStateShort())
fan.disconnect()
# Find temperature
pos = state.find("Temp=")
pos2 = state.find(",",int(pos))
Temp = state[pos+5:pos2]
# Find humidity
pos = state.find("Humidity=")
pos2 = state.find(",",int(pos))
Hum = float(state[pos+9:pos2])/10
Hum = str(Hum)
# Find light
pos = state.find("Light=")
pos2 = state.find(",",int(pos))
Lux = state[pos+6:pos2]
# Find speed
pos = state.find("RPM=")
pos2 = state.find(",",int(pos))
RPM = state[pos+4:pos2]
Flow = round(0.0137 * float(RPM) - 3.59,1)
httpurl = 'http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=30&nvalue=0&svalue=' + Temp + ';' + Hum + ';0'
r = requests.get(httpurl)
httpurl = 'http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=31&svalue=' + Lux
r = requests.get(httpurl)
httpurl = 'http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=32&nvalue=0&svalue=' + str(Flow)
r = requests.get(httpurl)
httpurl = 'http://127.0.0.1:8080/json.htm?type=command¶m=udevice&idx=33&nvalue=0&svalue=' + str(round(int(RPM)/2500*100,1))
r = requests.get(httpurl)