rgerganov / py-air-control

Command line app for controlling Philips air purifiers
MIT License
266 stars 53 forks source link

airctrl command not work without sudo #50

Closed lhttony closed 4 years ago

lhttony commented 4 years ago

Hello, I can confirm my purifier is using plain_coap with below command but it's only work with sudo.

sudo airctrl --ipaddr 192.168.1.40 --protocol plain_coap [name] Name: AirPurifier [modelid] ModelId: AC4558/31 [swversion] Version: 1.0.1 [StatusType] StatusType: localcontrol [ota] Over the air updates: no [Runtime] Runtime: 12.46 hours [pwr] Power: ON [pm25] PM25: 4 [iaql] Allergen index: 1 [mode] Mode: AG [om] Fan speed: a [aqil] Light brightness: 1 [uil] Buttons light: ON [ddp] Used index: PM2.5 [cl] Child lock: False [fltsts0] Pre-filter and Wick: clean in 23 hours [fltsts1] HEPA filter: replace in 3368 hours [fltsts2] Active carbon filter: replace in 0 hours

If I test it with airctrol command without sudo, may I know how can I permit such access to fix it ?

7/5/2020, 11:54:49 AM Traceback (most recent call last): 7/5/2020, 11:54:49 AM File "/home/hoobs/.hoobs/node_modules/philips-air/pyaircontrol.py", line 123, in 7/5/2020, 11:54:49 AM main() 7/5/2020, 11:54:49 AM File "/home/hoobs/.hoobs/node_modules/philips-air/pyaircontrol.py", line 104, in main 7/5/2020, 11:54:49 AM print(c.get_status()) 7/5/2020, 11:54:49 AM File "/home/hoobs/.hoobs/node_modules/philips-air/pyaircontrol.py", line 68, in get_status 7/5/2020, 11:54:49 AM status = self._client.get_status(False) 7/5/2020, 11:54:49 AM File "/home/hoobs/.local/lib/python3.7/site-packages/pyairctrl/plain_coap_client.py", line 220, in get_status 7/5/2020, 11:54:49 AM status = self._get() 7/5/2020, 11:54:49 AM File "/home/hoobs/.local/lib/python3.7/site-packages/pyairctrl/plain_coap_client.py", line 50, in _get 7/5/2020, 11:54:49 AM self._send_hello_sequence(client) 7/5/2020, 11:54:49 AM File "/home/hoobs/.local/lib/python3.7/site-packages/pyairctrl/plain_coap_client.py", line 83, in _send_hello_sequence 7/5/2020, 11:54:49 AM self._send_over_socket(self.server, packet) 7/5/2020, 11:54:49 AM File "/home/hoobs/.local/lib/python3.7/site-packages/pyairctrl/plain_coap_client.py", line 38, in _send_over_socket 7/5/2020, 11:54:49 AM s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, protocol) 7/5/2020, 11:54:49 AM File "/usr/lib/python3.7/socket.py", line 151, in init 7/5/2020, 11:54:49 AM _socket.socket.init(self, family, type, proto, fileno) 7/5/2020, 11:54:49 AM PermissionError: [Errno 13] Permission denied

It was installed with below steps running in a raspberry pi:

  1. flashed raspberry pi with homebridge from the official image https://github.com/homebridge/homebridge-raspbian-image/releases/tag/v1.0.7
  2. sudo apt install python3-pip git
  3. sudo pip3 install py-air-control
  4. sudo pip3 install -U git+https://github.com/Tanganelli/CoAPthon3@89d5173.
rgerganov commented 4 years ago

You can take a look at PR #49 for instructions how to run the program without root. I will merge it soon.

rgerganov commented 4 years ago

The README is updated on how to run it without root