rgerganov / py-air-control

Command line app for controlling Philips air purifiers
MIT License
256 stars 52 forks source link

Get data in python #74

Closed NikDevx closed 3 years ago

NikDevx commented 3 years ago

Hello How I can get data from python script? I would like to get temp data from response. Is it possible?

I try this

from pyairctrl import airctrl

response = airctrl.CoAPCli(host="192.168.0.10").get_status()
print(response['temp'])

But I got this one

2021-02-28 20:28:46,236 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.0.10', 5683), None-None, POST-PO, [Uri-Path: sys, Uri-Path: dev, Uri-Path: sync, ] 00AA58F6...8 bytes
2021-02-28 20:28:46,236 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.0.10', 5683), CON-45685, POST-PO, [Uri-Path: sys, Uri-Path: dev, Uri-Path: sync, ] 00AA58F6...8 bytes
2021-02-28 20:28:46,237 - Thread-1   - coapthon.client.coap - DEBUG - Start receiver Thread
2021-02-28 20:28:46,238 - MainThread-Retry-45685 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2021-02-28 20:28:46,724 - Thread-1   - coapthon.client.coap - DEBUG - receive_datagram - From ('192.168.0.10', 5683), To None, NON-45685, CONTENT-PO, [Content-Type: 0, ] 0945B15B...8 bytes
2021-02-28 20:28:46,724 - Thread-1   - coapthon.layers.messagelayer - DEBUG - receive_response - From ('192.168.0.10', 5683), To None, NON-45685, CONTENT-PO, [Content-Type: 0, ] 0945B15B...8 bytes
2021-02-28 20:28:46,724 - Thread-1   - coapthon.client.coap - DEBUG - Waiting for retransmit thread to finish ...
2021-02-28 20:28:46,724 - MainThread-Retry-45685 - coapthon.client.coap - DEBUG - retransmit loop ... exit
2021-02-28 20:28:46,737 - MainThread - coapthon.layers.messagelayer - DEBUG - send_request - From None, To ('192.168.0.10', 5683), None-None, GET-None, [Uri-Path: sys, Uri-Path: dev, Uri-Path: status, Observe: 0, ] No payload
2021-02-28 20:28:46,737 - MainThread - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.0.10', 5683), CON-45686, GET-None, [Uri-Path: sys, Uri-Path: dev, Uri-Path: status, Observe: 0, ] No payload
2021-02-28 20:28:46,739 - MainThread-Retry-45686 - coapthon.client.coap - DEBUG - retransmit loop ... enter
2021-02-28 20:28:46,794 - Thread-1   - coapthon.client.coap - DEBUG - receive_datagram - From ('192.168.0.10', 5683), To None, CON-1960, CONTENT-None, [Observe: 0, Content-Type: 50, Max-Age: 60, ] 00AA58F78F977AF9456E...1142 bytes
2021-02-28 20:28:46,794 - Thread-1   - coapthon.layers.messagelayer - DEBUG - receive_response - From ('192.168.0.10', 5683), To None, CON-1960, CONTENT-None, [Observe: 0, Content-Type: 50, Max-Age: 60, ] 00AA58F78F977AF9456E...1142 bytes
2021-02-28 20:28:46,794 - Thread-1   - coapthon.client.coap - DEBUG - Waiting for retransmit thread to finish ...
2021-02-28 20:28:46,794 - MainThread-Retry-45686 - coapthon.client.coap - DEBUG - retransmit loop ... exit
2021-02-28 20:28:46,807 - Thread-1   - coapthon.layers.messagelayer - DEBUG - send_empty - From None, To None, ACK-None, EMPTY-None, [] No payload
2021-02-28 20:28:46,807 - Thread-1   - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.0.10', 5683), ACK-1960, EMPTY-None, [] No payload
2021-02-28 20:28:46,808 - Thread-1   - coapthon.layers.messagelayer - DEBUG - send_empty - From None, To None, ACK-None, EMPTY-None, [] No payload
2021-02-28 20:28:46,808 - Thread-1   - coapthon.client.coap - DEBUG - send_datagram - From None, To ('192.168.0.10', 5683), ACK-1960, EMPTY-None, [] No payload
Message from device got corrupted
Raw status:
{}
2021-02-28 20:28:46,913 - Thread-1   - coapthon.client.coap - DEBUG - Exiting receiver Thread due to request