alextud / ha-prana

Prana recuperators (fan) for Home Assistant
23 stars 2 forks source link

Does it still work with current HA? #4

Open Jokeru18 opened 2 years ago

Jokeru18 commented 2 years ago

I have tried to install it with HACS on current version and when I try to add the integration I get an error. After I have the error, the integration is not visible in the list anymore. I cannot try to add it again. However I can find the Prana Recuperator.. CO2, Speed under Entities but cannot d anything with them.

I also tried to Downgrade HA core to an older version(2021.7.1), but I cannot even get the integration to show up in the list?

Any advice? I have Prana 200C Pemium

Jokeru18 commented 2 years ago

This is the log I get As far as I can see the integration is setup correctly but Prana does not respond to connection. or?

2022-01-16 07:14:56 DEBUG (PranaWorker) [custom_components.prana] Updating Prana device... 34:86:5d:10:06:62 2022-01-16 07:14:56 DEBUG (Thread-3) [custom_components.prana.prana] Sending command BEEF0501000000005A to prana 34:86:5d:10:06:62 2022-01-16 07:14:56 DEBUG (Thread-3) [custom_components.prana.prana] Connecting to Prana... 2022-01-16 07:14:56 DEBUG (Thread-3) [custom_components.prana.prana] Error talking to prana. Traceback (most recent call last): File "/config/custom_components/prana/prana.py", line 114, in sendCommand_raw device = btle.Peripheral(self.mac) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 391, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 34:86:5d:10:06:62, addr type: public 2022-01-16 07:14:56 DEBUG (Thread-3) [custom_components.prana.prana] Cannot connect to Prana. Retrying (remaining: 2)... 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Sending command BEEF0501000000005A to prana 34:86:5d:10:06:62 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Connecting to Prana... 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Error talking to prana. Traceback (most recent call last): File "/config/custom_components/prana/prana.py", line 114, in sendCommand_raw device = btle.Peripheral(self.mac) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 391, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 34:86:5d:10:06:62, addr type: public 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Cannot connect to Prana. Retrying (remaining: 1)... 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Sending command BEEF0501000000005A to prana 34:86:5d:10:06:62 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Connecting to Prana... 2022-01-16 07:14:57 DEBUG (Thread-3) [custom_components.prana.prana] Error talking to prana. Traceback (most recent call last): File "/config/custom_components/prana/prana.py", line 114, in sendCommand_raw device = btle.Peripheral(self.mac) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 391, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 34:86:5d:10:06:62, addr type: public 2022-01-16 07:14:57 ERROR (Thread-3) [custom_components.prana.prana] Prana communication failed. Stopping trying. 2022-01-16 07:14:57 DEBUG (PranaWorker) [custom_components.prana.prana] result = 0 2022-01-16 07:14:57 DEBUG (PranaWorker) [custom_components.prana] Update failed...

alextud commented 2 years ago

Hey @Jokeru18, can you try to use the iPhone app, at the same place where HA is placed ? maybe HA is placed to far away from the Prana device, and is not been able to communicate ... so we can check that iPhone app is working ...

Jokeru18 commented 2 years ago

Hi, Thank you for the reply. I was thinking of this posibility so I moved the Laptop in the room where the Prana recuperator is placed but still no luck. BTW: I'm Runing a virtual machine under windows 10. but the BT 4.0 device is shared with the Virtual machine.

I tried installing HA core straight on linux but I keep running into issues so I opted for this possibiliy.

PS: I confgured a fresh install of HA today, jut to make sure the issue is not some previous config... but it still behaves the same. *Prana communication failed. Stopping trying. PRANA *

Jokeru18 commented 2 years ago

I see in the manifest it sais "requirements": ["bluepy==1.3.0"]. maybe this is why it is not working BUt how to I install or check for bluepy in Home Assistant Operating System. Terminal does not allow any of the regular commands.

Jokeru18 commented 2 years ago

I have tried everything. I even installed Home Asssistant Supervised directly in Ubuntu to avoid using a virtual machine but the behavior is the same. Checked and Bluepy 1.3.0 is installed under Python 3.9 I can see that the Bluetooth in Linux shows a connection so it connects to the device but the log looks the same: Connecting to prana Connected to prana Error talking to prana ..

I have no password on the Prana. No other divice is connected to it. Laptop is 2m away from the Reruperator

I don't know what's wrong, could it be hardware related? The Bluetooth device is Intel, comes with Dual Band wireless AC-3160.

alextud commented 2 years ago

Can you try to test bluetooth connection using one these 2 cli tools bluetoothctl or gatttool ?

EX 1:

sudo bluetoothctl 
connect MAC_ADDRESS
menu gatt
select-attribute 0000cccc-0000-1000-8000-00805f9b34fb
notify on
write "0xBE 0xEF 0x05 0x01 0x00 0x00 0x00 0x00 0x5A"

EX 2:

gatttool -b MAC_ADDRESS -I
connect
char-write-req 0x000f 0100
mtu 200
char-write-req 0x000e BEEF0501000000005A
Jokeru18 commented 2 years ago

With the first ex. I get stuck at menu gatt. It answers with a list of commands. It also refreshes available devices like crazy.

Second one looks like this:

gatttool -b 34:86:5d:10:06:62 -I [34:86:5d:10:06:62][LE]> connect Attempting to connect to 34:86:5d:10:06:62 Connection successful [34:86:5d:10:06:62][LE]> char-write-req 0x000f 0100 Error: Characteristic Write Request failed: Invalid handle [34:86:5d:10:06:62][LE]> mtu 200 MTU was exchanged successfully: 200 [34:86:5d:10:06:62][LE]> char-write-req 0x000e BEEF0501000000005A Error: Characteristic Write Request failed: Invalid handle [34:86:5d:10:06:62][LE]> gatttool

alextud commented 2 years ago

I think that your device is not supported, it is using a different communication handle (address) .

Jokeru18 commented 2 years ago

I tried again Ex. 1 and I think I had more success

[PRANA RECUPERATOR       ]# list-attributes
Primary Service (Handle 0x0009)
    /org/bluez/hci0/dev_34_86_5D_10_06_62/service0001
    00001801-0000-1000-8000-00805f9b34fb
    Generic Attribute Profile
Characteristic (Handle 0xd0e4)
    /org/bluez/hci0/dev_34_86_5D_10_06_62/service0001/char0002
    00002a05-0000-1000-8000-00805f9b34fb
    Service Changed
Descriptor (Handle 0x0015)
    /org/bluez/hci0/dev_34_86_5D_10_06_62/service0001/char0002/desc0004
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
Primary Service (Handle 0xf920)
    /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028
    0000baba-0000-1000-8000-00805f9b34fb
    Unknown
Characteristic (Handle 0x1214)
    /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028/char0029
    0000cccc-0000-1000-8000-00805f9b34fb
    Unknown
Descriptor (Handle 0x0015)
    /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028/char0029/desc002b
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
[PRANA RECUPERATOR       ]# select-attribute 0000cccc-0000-1000-8000-00805f9b34fb
[PRANA RECUPERATOR       :/service0028/char0029]# notify on
[CHG] Attribute /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028/char0029 Value:
  00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e     ............... 
[CHG] Attribute /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028/char0029 Notifying: yes
Notify started
[PRANA RECUPERATOR       :/service0028/char0029]# write "0xBE 0xEF 0x05 0x01 0x00 0x00 0x00 0x00 0x5A"
Attempting to write /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028/char0029
[CHG] Attribute /org/bluez/hci0/dev_34_86_5D_10_06_62/service0028/char0029 Value:
  be ef 05 01 00 00 00 00 5a c0 01 c0 08 c0 01 c0  ........Z.......
  00 c0 00 00 00 c0 00 40 01 40 1e c0 01 c0 1e c0  .......@.@......
  01 c0 0a 00 00 80 00 00 00 c0 01 00 01 00 00 00  ................
  80 77 00 00 00 00 80 c8 00 00 00 00 aa 00 00 00  .w..............
  00 00 00 00 00 00 00 00 00 00 00 00 00 82 e0 00  ................
  00 00 00 00 00 00 00 00 00 00 00 00 00 ff c0 00  ................
  00 00 00 00 01 00 3c e9 fe                       ......<..       
[PRANA RECUPERATOR       :/service0028/char0029]# 
Jokeru18 commented 2 years ago

So I was playing some more with gatttool trying to understand more and I found that I can manually send commands and they work. If I send this **char-write-cmd 0x002a BEEF0405** it turns on Heat so they actually correspond to the ones you have in Prana.py

I ended up to the handle -0x002a by drilling down and if I use char-read-hnd 0x002a I get Characteristic value/descriptor: 95 ef 05 02 00 00 00 00 5a 00 00 00 00 00 00 00 01 50 52 41 4e 41 20 52 45 43 55 50 45 52 41 54 4f 52 20 20 20 20 20 20 20 03 f0 03 f2 03 f4 03 f6 11 00 00 00 00 00 00 04 00 20 0a 0a 0a 64 64 64 01 09 01 03 0a 64 0a 0a 64 0a 0a 64 0a 00 01 1e 05 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 ad 2b e9 fe 6b a4 e1 8e 8b 90 1f 41 a5 b6 36 5a 7a 29 cf 33 fe bf 50 5b 26 a3 7b 96 a3 9b fa 86 92 1f 68 76 0c 08 31 01 00 12 00 00 00 4d 3e 56 9f b3 55 75 7e f2 34 6d ae 21 2e

Any sugestions? What shoudl I should change in the integration files?

Thank you!

alextud commented 2 years ago

I found a different opensource integration for Prana, can you try to see if this one works for you ?

https://github.com/corvis/prana_rc

it might have a slightly different implementation than mine ...

Jokeru18 commented 2 years ago

Hi, yes it works But there are some issues with the HTTP server as it randomly stops sending data to HA and needs to be restarted. It also doesn't support independent in/out flow setup.

busutm commented 2 years ago

Hi, i have the same problem. i installed homeassistant via vm with proxmox. prana

2022-02-11 09:12:46 DEBUG (PranaWorker) [custom_components.prana] Updating Prana device... A8:03:2A:E6:85:06 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Sending command BEEF0501000000005A to prana A8:03:2A:E6:85:06 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Connecting to Prana... 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Error talking to prana. Traceback (most recent call last): File "/config/custom_components/prana/prana.py", line 114, in sendCommand_raw device = btle.Peripheral(self.mac) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 391, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral A8:03:2A:E6:85:06, addr type: public 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Cannot connect to Prana. Retrying (remaining: 2)... 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Sending command BEEF0501000000005A to prana A8:03:2A:E6:85:06 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Connecting to Prana... 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Error talking to prana. Traceback (most recent call last): File "/config/custom_components/prana/prana.py", line 114, in sendCommand_raw device = btle.Peripheral(self.mac) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 391, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral A8:03:2A:E6:85:06, addr type: public 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Cannot connect to Prana. Retrying (remaining: 1)... 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Sending command BEEF0501000000005A to prana A8:03:2A:E6:85:06 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Connecting to Prana... 2022-02-11 09:12:46 DEBUG (Thread-33) [custom_components.prana.prana] Error talking to prana. Traceback (most recent call last): File "/config/custom_components/prana/prana.py", line 114, in sendCommand_raw device = btle.Peripheral(self.mac) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 391, in init self._connect(deviceAddr, addrType, iface) File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 439, in _connect raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp) bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral A8:03:2A:E6:85:06, addr type: public 2022-02-11 09:12:46 ERROR (Thread-33) [custom_components.prana.prana] Prana communication failed. Stopping trying. 2022-02-11 09:12:46 DEBUG (PranaWorker) [custom_components.prana.prana] result = 0 2022-02-11 09:12:46 DEBUG (PranaWorker) [custom_components.prana] Update failed...

alextud commented 2 years ago

I use home-assistant trough docker.

I've tried to connect to Prana with another python library - bleak that is used by corvis project and it did not work for me. Currently I use bluepy library, in your case it seems that it's not connecting so I assume that is related to environment/hardware used.

Jokeru18 commented 2 years ago

Thanks for taking the time! For me it sais Connectign to prana, Connected to prana, Error talking to prana. and I see on the Blueman icon that it is making a connection and after a while is disconnecting. However I couldn't figure out why it is not working. Maybe is something specific to the HW in the prana, mine is 200C premium with wifi. I tried commenting all the CO2 and VOC lines thinking this could be it but ...no go. Bluepy 1.3.0 is installed in Python 3.9 library.... For the moment I gave up trying as I tested all possibilities. Virtual Machine, WLS2, Docker under Ubuntu 20.04, Docker under Debian 11, Supervised under Debian 11.

I somehow found a way to make the other integration, suggested by you, stable. I'm restating the Prana_rc server regularly with Cronetab and I replaced the command winter mode switch withspeedInUp = "BEEF040E" and now I can have automations with different speeds for in and out.