Closed cyberfly79 closed 3 years ago
Generally it should work from the docker but I didn't tried yet. It relies on D-Bus underneath so as long as you can share D-Bus of the host with container it should work.
Anyway it is not ready yet. I started to work on this a few days ago and so far just implemented command line interface and the a few basic commands like set speed turn on\off heating etc.
The plan is to complete implementation Prana API and then wrap everything into Home Assistant module. Home Assistant module will be in a separate repo here: https://github.com/corvis/homeassistant_prana (so far it's empty). You could subscribe to watch updates as I have pretty simmilar configuration to what you have - home assistant into docker, prana 150.
I tried to install (pip) but there is always some syntax error.
Traceback (most recent call last):
File "/usr/local/bin/prana", line 11, in
Try newer version of python. The syntax in the line 67 is not compatible with 3.5.
On Wed, Jun 10, 2020 at 3:50 PM cyberfly79 notifications@github.com wrote:
I tried to install (pip) but there is always some syntax error.
Traceback (most recent call last): File "/usr/local/bin/prana", line 11, in load_entry_point('prana-rc==0.2.0', 'console_scripts', 'prana')() File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 561, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2631, in load_entry_point return ep.load() File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2291, in load return self.resolve() File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2297, in resolve module = import(self.module_name, fromlist=['name'], level=0) File "/usr/lib/python3.5/prana_rc/init.py", line 27, in from prana_rc import cli File "/usr/lib/python3.5/prana_rc/cli.py", line 22, in from prana_rc.cli_utils import CliExtension, register_global_arguments, CLI, parse_bool_val, parse_speed_str File "/usr/lib/python3.5/prana_rc/cli_utils.py", line 22, in from prana_rc.entity import Speed File "/usr/lib/python3.5/prana_rc/entity.py", line 67 address: str ^ SyntaxError: invalid syntax
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/corvis/prana_rc/issues/1#issuecomment-641984975, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKVUD6H5244IX2WWSYIMK3RV56R7ANCNFSM4MG64TMA .
-- Yours sincerely, Dmitry Berezovsky
Hi guys, hope you don't mind if I'm asking here: any updates on this? I'm in the same situation: Prana 150, an outside PM monitoring station and an indoor air quality sensor. I would love to integrate them all in HA and create some automations. Thanks
Hey everyone,
Unfortunately I still haven't build HA integration piece. At the same time the code in this repository seems to work fine, it gives you CLI interface so you should be able to implement very simplistic automation just by calling executable with corresponding parameters.
As for the docker - I briefly tested this and it seems to work just fine IF you run container in network = host
mode. Hope this helps as an interim solution. I still have a plan to implement a proper integration with HA.
Thanks Dmitri for your quick reply. Can't wait for HA integration :). Meanwhile I'll install a raspbian on my Pi and I'll try to understand how to run the python script. If you need any help in testing please let me know
Guys, I know it might sound stupid but ... how can I run these scripts? With pip? I've downloaded and extracted the archive, it looks like this: pi@raspberrypi:~/prana_rc-master $ ls -alh total 92K drwxr-xr-x 4 pi pi 4.0K Apr 13 21:02 . drwxr-xr-x 6 pi pi 4.0K Aug 25 17:29 .. -rw-r--r-- 1 pi pi 1.8K Apr 13 21:02 .gitignore -rw-r--r-- 1 pi pi 35K Apr 13 21:02 LICENSE -rw-r--r-- 1 pi pi 1.9K Apr 13 21:02 README.md -rwxr-xr-x 1 pi pi 1.5K Apr 13 21:02 build.sh drwxr-xr-x 2 pi pi 4.0K Apr 13 21:02 development -rw-r--r-- 1 pi pi 24K Apr 13 21:02 prana_pic.jpg -rw-r--r-- 1 pi pi 109 Apr 13 21:02 requirements.txt drwxr-xr-x 3 pi pi 4.0K Apr 13 21:02 src
Hey @ValiEne
You don't need to download anything from github. The process should be the following:
python3 --version
sudo pip install prana-rc
prana discover
A couple notes:
Thanks Dmitri, sorry for being so dumb :)) Unfortunately it doesn't work on my Pi4B: Please see below the output:
_pi@raspberrypi:~ $ sudo python3 --version
Python 3.7.3
pi@raspberrypi:~ $ sudo pip install prana-rc
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting prana-rc
Downloading https://files.pythonhosted.org/packages/db/de/d2f5bf311788830da81c9e31c20a485e48a40b5bf8805fb2dc0fd60ce847/prana_rc-0.2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "
----------------------------------------
Command "python setup.py egginfo" failed with error code 1 in /tmp/pip-install-3L4xMT/prana-rc/
The bluetooth looks to work fine: sudo hcitool -i hci0 lescan LE Scan ... ======part removed========= 00:A0:50:00:00:03 PRANA recuperator ======part removed=========
Could you please ensure you use pip from the python 3 installation, not python 2.most likely you have both. Try to remove package first
sudo pip uninstall prana-rc
And then install using pip3:
sudo pip3 install prana-rc
The error you posted means the python interpreter which is in use doesn't support modern syntax which makes me think this is an installation issue.
Thanks Dmitri, It worked after running the commands you wrote above. Unfortunately the app doesn't discover my Prana 150. Same results when running the script on MacOS What's super strange is that when I'm running "sudo hcitool -i hci0 lescan" on RaspPi I can see the vent, as you can see on the output above
Hmm, it looks like your prana device broadcasts it's name in a slightly different format...
My device reports it's name as PRNAQaqRecuperator
by default. If you change the name in app settings it transofrms into PRNAQaqYOUR_NAME
. Anyway I thought the this prefix PRNAQaq
is static and play the role of unique descriminator of devices familly. But according to you logs the name is PRANA recuperator
so clearly my assumption was wrong... Not sure why there is a difference, brobably firmware is different... Any way it would be good to know to figure out if naming is the only difference or binary protocol was changed as well.
Could you please try the following:
prana -d 00:A0:50:00:00:03 status
if this works then
prana -d 00:A0:50:00:00:03 set -m high
I'm very curious to see if it will work, please keep me posted. If both of the commands work it would be fantastic if you test the rest of the features and report results here so we know if protocol is still compatible... By the way when did you bought your device?
Hi Dmitri, It works but with some "hiccups" Please see the output below:
pi@raspberrypi:~ $ sudo prana -d 00:A0:50:00:00:03 set -s 1 Connecting to 00:A0:50:00:00:03... -> ERROR: org.bluez.Error.Failed: Software caused connection abort Reconnecting... Attempt #2 -> ERROR: org.bluez.Error.Failed: Software caused connection abort Reconnecting... Attempt #3 -> ERROR: org.bluez.Error.Failed: Software caused connection abort Reconnecting... Attempt #4 Connected Setting speed to 1... -> ERROR: pi@raspberrypi:~ $ sudo prana -d 00:A0:50:00:00:03 status Connecting to 00:A0:50:00:00:03... -> ERROR: Services discovery error Reconnecting... Attempt #2 -> ERROR: Services discovery error Reconnecting... Attempt #3 -> ERROR: Services discovery error Reconnecting... Attempt #4 -> ERROR: org.bluez.Error.Failed: Software caused connection abort Reconnecting... Attempt #5 Connected Prana state: RUNNING, Speed: 1, Winter Mode: False, Heating: False, Flows locked: True
I see... May I ask you to play a bit more with it to figure out what works, what doesn't work?
It would be great to make a more or less clear expiriment and a) reboot rpi b) disconnect and connect prana from electricity (if possible). Then try to run all available commands (see the list prana <command> -h
).
We need to figure out:
Thank you for your help, D.
Aside note. Reconnection attempts might be related to this issue in underlying libraries: https://github.com/hbldh/bleak/issues/239
I've tried reseting both RaspPi and Prana, same results. I've checked all possible commands and they work fine, the only issue are those retries (it retries for a number of times: from 0 to 10, but in the end the command runs fine). I have also run commands with verbose on and I got this type of errors:
Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 153, in connect ).asFuture(self.loop) txdbus.error.RemoteError: org.bluez.Error.Failed: Software caused connection abort
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 153, in connect ).asFuture(self.loop) txdbus.error.RemoteError: org.bluez.Error.Failed: Software caused connection abort
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/prana_rc/cli_utils.py", line 74, in connect_to_device device = await self.device_manager.connect(args.device, args.timeout, attempts=1) File "/usr/local/lib/python3.7/dist-packages/prana_rc/service.py", line 82, in connect raise e File "/usr/local/lib/python3.7/dist-packages/prana_rc/service.py", line 78, in connect await device.connect(timeout) File "/usr/local/lib/python3.7/dist-packages/prana_rc/service.py", line 147, in connect await self.__client.connect(timeout=timeout) File "/usr/local/lib/python3.7/dist-packages/bleak/backends/bluezdbus/client.py", line 164, in connect raise BleakError(str(e)) bleak.exc.BleakError: org.bluez.Error.Failed: Software caused connection abort Reconnecting... Attempt #3 Connected Setting speed to 0... Recent device status: Prana state: IDLE, Speed: 0, Winter Mode: False, Heating: False, Flows locked: True
I found a good home assistant component that has been working almost perfectly for 1 month now. You can find it here: https://github.com/alextud/ha-prana
Thanks @cyberfly79 if it really works well then it might be a solution for most of the users, not for me unfortunately as it must run on the HomeAssistent server (it uses local bluetooth module) and in my case HASS and Prana are too far so I'm going to build HASS integration capable to use remote node to control prana.
@ValiEne recently I published updated version 0.2.1 which might resolve failed connection issues. If you still could check I'll be greatfull. in order to upgrade run sudo pip3 uninstall prana-rc
and then sudo pip3 install prana-rc
Yes, unfortunately the server is far away for me too. I put a raspberry pi near it that also has the home assistant on it. The server takes over from the slave: https://github.com/lukas-hetzenecker/home-assistant-remote
Didn't know about remote home assistant! Anyway I prefer to avoid runing multiple HASSes. My idea is to a) extend the conde in this repo to expose Websocket interface b) implement HASS plugin which could use either local BLE module or connect via websocket to the remote device (I have a few orange PI zeros). As my remote hardware is not that performant I'd like to deploy somethign super-lightweight and stateless.
@cyberfly79 I've tried the component you've pointed: it didn't worked for me: it works from time to time but it was totally unreliable - most of the times I was unable to set the speed etc
@ValiEne I'll be grateful if you could confirm or refute if the latest version resolves reliability issues. Please see instructions in the message above.
@corvis the latest version works perfect! All the commands are working as expected and only once I got a connection retry. Discovery still does'n work for me but it's not an issue. Now, the next step: how can I interact with the fan (I'm using Raspbian on my RPi4) from Home Assistant?
I mean: I know that I can run a remote ssh command on Raspbian but how can I get the status of the fan?
I'm in the same situation with you @corvis, I need to run the prana app on a remote machine as my main HA instance runs on my Synology NAS, so no bluetooth on HA
Great to hear the new version works more stable.
Not sure I've got the question... Assuming you'd like to invoke this from HASS you might want to try https://www.home-assistant.io/integrations/sensor.command_line and put ssh command here.
If the question is how to parse the output of status command - you could try to pipe output from stderr/stdout to some tools like awk or sed.
What I can do for you relatively quickly and easily is to extend the CLI tool to return status in JSON so you could pass it directly to HASS sensor like in this example:
Again this is a temporary solution - the proper one I'm going to implement I described above... but can't promise it will be soon enough.
It would be great if you could implement the json workaround until you have enough spare time to make it work directly in HA. Thanks for your time
Implemented in version 0.2.2. Added global option -f / --format
which allows to specify state output format. So you can run it like this: prana -d xxxxxxxxxxxxxxxxxxx -f json status
the same option will force set
command to output JSON instead of text in the same way.
Also, not it should output state into stdout and the rest e.g. error messages and status notifications into stderr which should make parsing more straightforward.
Please note, I don't have access to prana device today so can't check it in real conditions but as the implementation is simple I hope it will work... pls let me know
Nope, it doesn't work:
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 status
Connecting to 00:A0:50:00:00:03...
Connected
Prana state: IDLE, Speed: 0, Winter Mode: False, Heating: False, Flows locked: True
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 -f json status
Connecting to 00:A0:50:00:00:03...
Connected
-> ERROR: Object of type datetime is not JSON serializable
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 -f json set -m high
Connecting to 00:A0:50:00:00:03...
Connected
Setting mode to Mode.HIGH...
Recent device status:
-> ERROR: Object of type datetime is not JSON serializable
ugh :( try 0.2.3 please
It looks good now:
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 -f json status
Connecting to 00:A0:50:00:00:03...
Connected
{"speed_locked": 10, "speed_in": 10, "speed_out": 10, "night_mode": false, "auto_mode": false, "flows_locked": true, "is_on": false, "mini_heating_enabled": false, "winter_mode_enabled": false, "is_input_fan_on": false, "is_output_fan_on": false, "timestamp": "2020-08-31T21:25:08.887402", "speed": 0}
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 -f json set -s 10
Connecting to 00:A0:50:00:00:03...
Connected
Setting speed to 10...
-> ERROR: Illegal state: device must be connected before running any commands
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 -f json set -s 10
Connecting to 00:A0:50:00:00:03...
Connected
Setting speed to 10...
-> ERROR:
root@raspberrypi:~# prana -d 00:A0:50:00:00:03 -f json set -s 10
Connecting to 00:A0:50:00:00:03...
Connected
Setting speed to 10...
Recent device status:
{"speed_locked": 10, "speed_in": 10, "speed_out": 10, "night_mode": false, "auto_mode": false, "flows_locked": true, "is_on": true, "mini_heating_enabled": false, "winter_mode_enabled": false, "is_input_fan_on": true, "is_output_fan_on": true, "timestamp": "2020-08-31T21:26:34.541762", "speed": 10}
Closing the issue as this thread became a bit unrelated to the topic. Anyway docker support is now implemented and described in the readme section
I use the Home-Assistant in a docker. I have a prana 150 recuperator, and I would like to query it and use it from my system. Can you upload to the docker hub system? Thanks