JQ-300/200/100 Indoor Air Quality Meter

Hi,

Looks like the add on doesn’t work with the forthcoming December update. Reports that it can’t find HTTP_OK in the consts.py file. Guess they’ve made some changes :frowning:

Logger: homeassistant.setup
Source: setup.py:153
First occurred: 15:47:57 (1 occurrences)
Last logged: 15:47:57

Setup failed for jq300: Unable to import component: cannot import name 'HTTP_OK' from 'homeassistant.const' (/usr/src/homeassistant/homeassistant/const.py)

Yes, the check home Assistant addon gives the same error. @Limych I have see some explanation in the releases notes.

I think more info here: Remove const.HTTP_* status constants by scop · Pull Request #58380 · home-assistant/core · GitHub

EDIT: I’ve pushed a PR to fix the issue: Replace HA HTTP_OK by HTTPStatus.OK by McGiverGim · Pull Request #73 · Limych/ha-jq300 · GitHub

3 Likes

There seems to be some sort of conflict in your change.

I think the conflict is not for my code, but my knowledge in python is very reduced… Let’s see if @Limych sees the change and gives some advice.

2 Likes

i tested your change, and it works.
The errors its throwing doesnt appear to be in your change, but elsewhere in the base class.

I’ve added this addon after I’ve updated HA to 2021.12. If you add this to your configuration.yaml file, it will give that HTTP OK error. So I have it commented out until it is fixed.

Hi
I’m having the same error if I try to update my homeassistant to 2021.12.3
General Errors:
- Component error: jq300 - cannot import name ‘HTTP_OK’ from ‘homeassistant.const’ (/usr/local/lib/python3.9/site-packages/homeassistant/const.py)

Can you elaborate what I need to do?
Thanks

Same error with me.

same error… any solution? or throw away the jq300?
anyway it doesn’t mean anything well

@Limych has not been here for two months - I hope he is ok.

Same here,

I have Home Assistant 2021.12.5
Check configuration gives error with the following:

Component error: jq300 - cannot import name ‘HTTP_OK’ from ‘homeassistant.const’ (/usr/src/homeassistant/homeassistant/const.py)

One more with the issue. Just subscribing to the topic in case a solution is found.

i just noticed the codeowner made some changes to the api file.
Limych/ha-jq300: JQ-300 Indoor Air Quality Meter Home Assistant Integration (github.com)
I tested the change and it works for me.

There may be another way to circumvent the cloud without changing the firmware.
After analysing the device communication with wireshark to see what it is sending and where (and finding this thread while researching it.) i found that the JQ-300 connects to an MQTT server with the hostname www.youpinyuntai.com with the IP 103.20.248.213 on TCP port 55450, including a clear text login with username and password (different from the login to the app) and then subscribes to a topic (appears to be random 16 alpha numeric chars), then starts to publish to topic “ypair/mqtt/hcho” (in my case).
It should be fairly simple to put a DNS record on the router that points the www.youpinyuntai.com to a local IP that can host an MQTT broker like one on the HA server configured to listen on port 55450.
The published messages are however looking like this:
Message: A3601C04B14386182F8E4350E4E25EB6A76A2EFC4E7075761A527934F46AD41CDD220888201469112E0E86DA8AEDE11B5B51DB023DB1780F#4a75b08c
This is obviously the sensor data encoded in some form, but if it can be decoded, then we can have local logging without the crappy cloud they offer, and not need to mess with the firmware.
Admittedly, it is not as “clean” solution as doing the polite cloud queries, and technically perhaps not as accessible either, but it would also futureproof the device as the cloud service will inevitably disappear at some point.

3 Likes

This is a really great find.
I will try this out.
I’m guessing that it’s data format should be something similar to how this product’s data format is
SM300D2-V02 7-in-1 sensor module
Take a look at the product details section which has an explanation for its data format.

what username/password does your device have?

I am getting the below result but no values in HA

2022-02-17 14:45:08 DEBUG (Thread-4) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b’blanked’
22-02-17 14:45:08 DEBUG (Thread-4) [custom_components.jq300.api] Received CONNACK (0, 0)
2022-02-17 14:45:08 DEBUG (Thread-4) [custom_components.jq300.api] Connected to MQTT
2022-02-17 14:45:08 DEBUG (Thread-4) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m238) []

This log shows that the module has successfully subscribed to data updates from the device. But I don’t see any message about getting this data.

I see a lot of messages like tthis in logs, but i even can’t see sensors in entities. Please help

2022-02-17 20:53:21 DEBUG (MainThread) [custom_components.jq300] Connecting to account ****y@gm**l.com

2022-02-17 20:53:21 DEBUG (MainThread) [custom_components.jq300.api] Connecting to cloud server

2022-02-17 20:53:21 DEBUG (MainThread) [custom_components.jq300.api] Requesting URL http://www.youpinyuntai.com:32086/ypyt-api/api/app/loginByEmail

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] _query ret 200

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] Start connecting to cloud MQTT-server

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] Updating devices list for account ec****y@gm**l.com

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] Requesting URL http://www.youpinyuntai.com:32086/ypyt-api/api/app/deviceManager

2022-02-17 20:53:25 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] _query ret 200

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.binary_sensor] Setup binary sensors for account ec****y@gm**l.com

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] Updating sensors state for account ***y@gm**l.com

2022-02-17 20:53:25 DEBUG (MainThread) [custom_components.jq300.api] Finished fetching ****y@gm**l.com device's sensors in 0.000 seconds

2022-02-17 20:53:26 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:26 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:26 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m1) []

2022-02-17 20:53:27 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:28 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:28 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:28 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m2) []

2022-02-17 20:53:29 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:30 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:30 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:30 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m3) []

2022-02-17 20:53:32 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:32 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:32 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:32 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m4) []

2022-02-17 20:53:34 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:34 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:34 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:34 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m5) []

2022-02-17 20:53:35 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:36 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:36 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:36 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m6) []

2022-02-17 20:53:37 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:37 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:37 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:37 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m7) []

2022-02-17 20:53:39 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:39 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:39 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:39 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m8) []

2022-02-17 20:53:41 DEBUG (Thread-3) [custom_components.jq300.api] Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'41068426_1645124005066'

2022-02-17 20:53:41 DEBUG (Thread-3) [custom_components.jq300.api] Received CONNACK (0, 0)

2022-02-17 20:53:41 DEBUG (Thread-3) [custom_components.jq300.api] Connected to MQTT

2022-02-17 20:53:41 DEBUG (Thread-3) [custom_components.jq300.api] Sending SUBSCRIBE (d0, m9) []