Philips Air Purifier

yes, it is not there :frowning:
this is my configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
panel_iframe:
  configurator:
    title: 'Configurator'
    url: 'http://192.168.100.XXX:XXX'
    icon: mdi:wrench 
tado:
  username: 
  password: 
device_tracker:
  - platform: tado
    username: 
    password: 
    home_id: 
fan:
  - platform: philips-airpurifier
    host: 192.168.100.36
    protocol: 2
    name: Philips Air Purifier
binary_sensor:
  - platform: car_wash
    weather: weather.gismeteo_daily

I see my air purifier connected in network under name MiCO, it is model PHILIPS AC3033/10.

I attempted to install hass.io with a vmdx file on my Hyper V (architecture x86_64), went through the install of the HACS and then the Philips AirPurifier (with COAP) integration. I had copied the same fan configuration as you except mine is at Protocol: 1.

The install first moaned about a missing coap module but after restarting the box I just got the custom integration for philips-airpurifier warning and it connected fine to the air purifier and the Phlips Air Purifier fan is visible

can you ping mico (possibly from the synology)? Does it resolve to 192.168.100.36? And can you port test that IP - Iā€™m assuming the COAP port is 5683? Mine (on protocol level 1 responds on port 80)
Alternatively you could test a similar config if you can put it in a virtual machine if itā€™s something to do with Synology?

So I did the same thing. I have used virtual ubuntu on virtualbox and install hass.io + hacs and then Philips AirPurifier (with COAP). I also get the same message like you. After restart the message was gone. But I do not see my purifier at all. I have also tried to use protocol 1 and 2. No luck.

I can ping the 192.168.100.36 in cmd, I am getting response. I have tried to use advanced port scanner to find open ports but it shows me nothing. Only what i found is the name of manufacturer: Shanghai MXCHIP Information Technology Co., Ltd. and name: MiCO.

Basically I see same behavior like on Synology.

Strange - unless this one doesnā€™t have any open ports - does the AirMatters app work on the mobile? In which case are you able to Network capture what goes through to the air purifier to see if there is any traffic destined from a working device.

Also for your home assistant have you got other devices attached that can communicate outside of docker ok?

Not sure if others on here have the same model that will be able to confirm if it works for them?

Hi, are you able to try the component https://github.com/shexbeer/philips-airpurifier instead as found by @ondrabanov making sure you set the Protocol version to 2?

1 Like

Home assistant is working. There is also communication with my tado (discovered in network) and my smart plugs.

App air matters is also getting info from purifier.
I have tried to port scan from laptop the ip address of purifier up to 50000 and nothing.
I think i need something to monitor traffic between router and purifier itself.

Meybe somebody can use this, i have found a Chinese web with firmwares for this purifierā€¦ i think.

https://code.aliyun.com/MXCHIP_iotad_zhaohongyu_projects/mico-os/commit/b0d0359787faebe664c5fc1c2c9a7af03d3255f6
My air purifier has firmware

Firmware Version: [email protected]

Hello,
of course this still doesnā€™t work for me, and I had not too much time. I dumped the communication of my phone and my purifier. It doesnā€™t use any icmp packet -which is not part of the CoAP- but doesnā€™t really matter if we send it. I think itā€™s just a misunderstaning though. In the dump Iā€™ve found for asking the /sys/dev/info so Iā€™ve tried and the purifier answered a json:

{"product_id":"<cut>","device_id":"<cut>","name":"Living Room","type":"AC3858","modelid":"AC3858/50","swversion":"Ms4102","option":"1"}

The product_id and the device_id seems like an md5 sum. The purifier didnā€™t answer any other request yet. The /sys/dev/control requests should be encoded, I donā€™t know yet what kind of encoding -probably aes- it uses and it answers probably the same method to the /sys/dev/status query. If someone has time -and knowledge- to debug I can provide the tcpdump.
It doesnā€™t matter if you try to portscan and it doesnā€™t find any open TCP port, seems the newer ones are communicating with UDP now.

Hi! Iā€™ve tried to add my AC2889/10 to HA via your custom component, but I get the following error log when starting HA:

Protokolldetails ( ERROR )
Logger: homeassistant.core
Source: custom_components/philips-airpurifier/airctrl.py:4 
First occurred: 22:30:50 (4 occurrences) 
Last logged: 22:37:58
	ā€¢	Error executing service <ServiceCall homeassistant.restart (c:cbb96c66f7c140a1b1bf69196ab3aa75)>
	ā€¢	Error executing service <ServiceCall homeassistant.restart (c:e5bf3ff2453b4ae0a28c01e517ae5fba)>
	ā€¢	Error executing service <ServiceCall homeassistant.restart (c:10f9544aacf049e798df67f065bd0ded)>
	ā€¢	Error executing service <ServiceCall homeassistant.restart (c:391fc482025641288f3278793861b329)>
Traceback (most recent call last):
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/core.py", line 1240, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/core.py", line 1255, in _execute_service
    await handler.func(service_call)
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/service.py", line 476, in admin_handler
    await result
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/__init__.py", line 107, in async_handle_core_service
    errors = await conf_util.async_check_ha_config_file(hass)
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/config.py", line 821, in async_check_ha_config_file
    res = await check_config.async_check_ha_config_file(hass)
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/check_config.py", line 164, in async_check_ha_config_file
    platform = p_integration.get_platform(domain)
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/homeassistant/loader.py", line 276, in get_platform
    cache[full_name] = importlib.import_module(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/myuser/.homeassistant/custom_components/philips-airpurifier/fan.py", line 3, in <module>
    from . import airctrl as air
  File "/Users/myuser/.homeassistant/custom_components/philips-airpurifier/airctrl.py", line 4, in <module>
    from coapthon.client.helperclient import HelperClient
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/coapthon/client/helperclient.py", line 6, in <module>
    from coapthon.client.coap import CoAP
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/coapthon/client/coap.py", line 14, in <module>
    from coapthon.serializer import Serializer
  File "/Users/myuser/homeassistant/lib/python3.8/site-packages/coapthon/serializer.py", line 223
    print values
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(values)?

what can I do to solve this? Thanks in advance :blush:

Any updates?

On github thereā€™s a newer pyairctrl with solving the problem of the air purifiers which are using encrypted coap payloads. Iā€™ve tried to apply it to homeassistant but didnā€™t work, Iā€™ll need to read more documentation but I donā€™t know when Iā€™ll have time for that.

I also got that working yesterday. I will try today to apply the new pyairctrl. @shexbeer do you have any updates on this topic?

I just bought Philips AC2729/50. Does the component work properly in the newest hassio version ? :slight_smile:

Iā€™d be interested to get this working. I have an AC2889/10, which requires the coap protocol. I can reach it with the airctrl command thatā€™s part of py-air-control, and get readouts of various values.
Short-term, Iā€™m thinking of writing something simple that publishes key values (air quality, temperature etc) to an MQTT topic at regular intervals, so I can monitor the device in HA even if I canā€™t control it.

Hello I have bought the philips AC1214 but I could get it work on Home Assistant.
When I set

fan:
  platform: philips-airpurifier
  host: 192.168.0.234
  protocol: 2

I get errors like this

Logboekdetails (WARNING)

Logger: homeassistant.config_entries
Source: config_entries.py:232
First occurred: 15:52:31 (1 occurrences)
Last logged: 15:52:31

Config entry for ipp not ready yet. Retrying in 80 seconds

And I get also a Tuya and IP Printing error.

Help, I really want my device in my home assistant. Any body a idea.

Iā€™m new on Home Assistant. May be I asked silly questions :wink:

I got this working with a Python script that uses the CoAPAirClient module from the py-air-control package. It obtains the current status from the AC2889 and publishes key values to an MQTT topic as well as storing them in a simple SQLite table. I defined sensors in HA to capture the Air Quality Index and PM25 values from MQTT, and I display these on a dashboard like this:


Pretty trivial, but a nice addition to the dashboard.

@MarkScott any chance you could show us the code?

Sure thing. No guarantees or promises here, itā€™s all just a lash-up but I hope it makes sense to you. You will obviously need to adapt it to your own environment with IP addresses of your own purifier and MQTT broker. Youā€™ll also need the Python packages py-air-control and paho-mqtt package (install these with pip3).

Below is the script (pfypub.py) that obtains the status, saves it to the database and publishes to MQTT. It runs every 10 minutes, invoked by a cron entry:

## Air quality from the Philips machine every 10 minutes
*/10 * * * * /usr/bin/python3 /home/pi/bin/pfypub.py
#!/usr/bin/env python3
# Obtain latest air quality data from Philips purifier
# Store in a little database table, and publish to MQTT

from datetime import datetime
from pyairctrl.coap_client import CoAPAirClient
import sqlite3
AQDB = '/home/pi/purifier/aq.db'

# MQTT broker
import paho.mqtt.client as mqtt
import json
BROKER = "172.28.16.24"
PORT = 1883
TOPIC = "air/bedroom"

# IP of the air filter
FILTER = "172.28.16.95"


class AirFilter:
    def __init__(self, host, port=5683, debug=False):
        self._client = CoAPAirClient(host, port, debug)
        self.status = self._client.get_status(debug)

    def get_quality(self):
        if self.status:
            return self.status["iaql"]

    def get_name(self):
        if self.status:
            return self.status["name"]

    def get_fanspeed(self):
        if self.status:
            return self.status["om"]

    def get_mode(self):
        if self.status:
            return self.status["mode"]

    def get_pm25(self):
        if self.status:
            return self.status["pm25"]

    def get_power(self):
        if self.status:
            return self.status["pwr"]


def main():

    timestamp = int(datetime.now().timestamp())

    bedroom = AirFilter(FILTER)

    name = bedroom.get_name()
    power = bedroom.get_power()
    fanspeed = bedroom.get_fanspeed()
    quality = bedroom.get_quality()
    pm25 = bedroom.get_pm25()
    mode = bedroom.get_mode()

    dbc = sqlite3.connect(AQDB)
    csr = dbc.cursor()
    sql = 'INSERT INTO airquality (Timestamp, Filtername, Powerstatus, Fanspeed, AirQualityIndex, PM25, Mode ) VALUES( {}, "{}", {}, {}, {}, {}, "{}" )'.format(timestamp, name, power, fanspeed, quality, pm25, mode)
    #print(sql)
    count = csr.execute(sql)
    dbc.commit()
    csr.close()
    dbc.close()

    adic = {"timestamp" : timestamp, 
            "name" : name,
            "power" : power,
            "fan" : fanspeed,
            "quality" : quality,
            "pm25" : pm25, 
            "mode" : mode}
    ajson = json.dumps(adic)

    #print(ajson)

    client = mqtt.Client()

    client.connect(BROKER, PORT)
    client.publish(TOPIC, ajson)
    client.disconnect()


if __name__ == '__main__':
    main()

The database is optional, I created it in sqlite3 with one table as follows:

CREATE TABLE airquality (
    Timestamp integer NOT NULL,
    Filtername text,
    Powerstatus integer,
    Fanspeed integer,
    AirQualityIndex integer,
    PM25 integer,
    Mode text,
    PRIMARY KEY (Timestamp)
    );

The HA sensor definitions are these:

# Air quality, obtained from Philips air purifier

- platform: mqtt
  state_topic: "air/bedroom"
  name: "Fan speed"
  unit_of_measurement: "Index"
  value_template: '{{ value_json.fan }}'
- platform: mqtt
  state_topic: "air/bedroom"
  name: "Air quality index"
  unit_of_measurement: "Index"
  value_template: '{{ value_json.quality }}'
- platform: mqtt
  state_topic: "air/bedroom"
  name: "PM25"
  unit_of_measurement: "Index"
  value_template: '{{ value_json.pm25 }}'

The dashboard card is this:

entities:
  - entity: sensor.air_quality_index
  - entity: sensor.pm25
hours_to_show: 24
refresh_interval: 600
title: Air quality
type: history-graph

Good luck!

Hi all and thanks for the work you have done

@shexbeer or anyone who can point me in the right direction

I have installed your integration from https://github.com/shexbeer/philips-airpurifier/tree/master/custom_components/philips-airpurifier

I also made sure that the requirements are installed (they were) directly into the container.

But still I get this error in HASS logs

2020-10-11 01:14:24 ERROR (MainThread) [homeassistant.components.fan] Error while setting up philips-airpurifier platform for fan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/philips-airpurifier/fan.py", line 40, in setup_platform
    add_devices([PhilipsAirPurifierFan(hass, config)])
  File "/config/custom_components/philips-airpurifier/fan.py", line 76, in __init__
    self.update()
  File "/config/custom_components/philips-airpurifier/fan.py", line 101, in update
    filters = self._get_filter()
  File "/config/custom_components/philips-airpurifier/fan.py", line 97, in _get_filter
    filters = self._client.get()
  File "/config/custom_components/philips-airpurifier/airctrl.py", line 337, in get
    return json.loads(response.payload)["state"]["reported"]
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 2 (char 1)

Iā€™m a little bit confused at the moment.

I would lik to connect a AC3829.
I installed this via HACS


and put this lines into my config
fan:
  platform: philips_airpurifier
  host: [humdifier IP]
  name: luftbefeuchter_AC3829 

There seems to happen sth. but it seems not working completely. The state of the created fan entity stays unavailable but i see the attributes speed_list, friendly_name, icon and supported_features.

Is the AC3829 currently working for someone and itā€™s only a problem for me, or is there a general problem with the component at the moment?