I couldn’t find any document which tells how to install homeassistant.remote. Could someone please help to install on my Ubuntu machine?
Thanks
What exactly do you mean by “remote”?
Cheers
Thanks for the reply.
I trying to use Python API for Home Assistant documented here https://home-assistant.io/developers/python_api/ and it needs remote component as shown below.
import homeassistant.remote as remote
When I try to install using the command
pip3 install homeassistant.remote
it gives me error saying:
Could not find a version that satisfies the requirement homeassistant.remote (from versions: )
No matching distribution found for homeassistant.remote
Hey homeassistant.remote comes with homeassistant. So you should already have it if you have installed HA. Maybe you run HA in a virtualenv and that’s why you can’t see it?
What kind of error do you get if you try to
import homeassistant.remote as remote
in a python console?
Thanks for pointing out that to me, I was not aware that’s part of HA.
But when I run my python script using following command:
python python_api_testing.py
which tries to use remote component I get following error.
File "python_api_testing.py", line 1, in <module>
import homeassistant.remote as remote
ImportError: No module named homeassistant.remote
Thanks for the help
Seems to me like homeassistant is not installed in the same env as your python. How did you install HA?
Also can you do a quick python -V for me?
Cheers
Looks like we are getting there to find the root cause.
python -V shows me python 2.7.12
I am running HA on Ubuntu. First when I installed I did using
pip3 install homeassistant
But when few days when I tried to upgrade it to 0.26.1 it gave me error for following command
pip3 install --upgrade homeassistant
So I did with sudo rather than my user called ‘home’ and it did work
sudo pip3 install --upgrade homeassistant
But since my upgrade I am not able to run history api and gives me error 404: Not found
That’s why you should always use virtualenv can you try running your script with python3 or python 3.4 or something like that?
When I tried with python3 it is giving me some other error: Error connecting to server.
That means the original error gone, that’s good sign.
I am new to Ubuntu and HA too. I am not even aware about virtualenv. When I installed HA on Ubuntu I though I had python 3.5, not sure when how it got downgraded to 2.7.12, may be Ubuntu system updates, or you said I may have multiple version of python.
When I run command
locate pip3
I am seeing 4 listings
/home/home/.local/bin/pip3
/home/home/.local/bin/pip3.5
/usr/bin/pip3
/usr/share/man/man1/pip3.1.gz
Should I uninstall older ones?
Any good source/document to setup/use virtualenv for Ubuntu please?
Appreciate your help and time,
First of all there is no downgrade. Ubuntu just has both versions of python installed. It might be that the “python” command you use just got linked to the 2.7 version. So you should always use python3.x or python2.7 to be sure which python you are currently using.
For virtualenv I can recommand the following guide:
http://docs.python-guide.org/en/latest/dev/virtualenvs/
Be sure to read first before you actually enter commands.
A virtualenv is basicly a directory which contains a whole python environment. (No need for “sudo pip install xxx”)
If you have further question feel free
Cheers
Wow, this was great help, thank you so much.
I will read and keep in mind about this virtualenv so when next I need to rebuild HA I will go that route.
Is there a way to know what version of python used by my HA instance?
May be then I can figure out why my HA RESTApi for history is giving me error 404: Not found.
Thanks a lot.
How did you install ha? Just with pip3 install upgrade? Because if so you could use
pip3 -V
to see which version of python this pip instance is using
Thanks a lot.
I installed it using
pip3 install homeassistant
Upgraded using
sudo pip3 install -upgrade homeassistant
When I run
pip3 -V
I get following
pip 8.1.2 from /home/home/.local/lib/python3.5/site-packages (python 3.5)
Well now you know your HA is running on python 3.5
Yes, and I am happy about it before I got bit worried.
Thanks for your time and help.
hi all, I know this is an old thread, but I am trying to understand why my python script cannot load the homeassistant.remote module. I am using a venv and when I do a pip3 list I see homeassistant installed. If I enter
import homeassistant.remote as remote
in a python3 console, it works fine. However, if I run a script that has that exact same line (copy/paste) using python3 it errors out and says it cannot load module homeassistant. How can that be? I opened the console as well as the script from the same venv…
Help?
How do you start your script? If you start it with python3 /path/to/script.py
it should start in the same environment.
I’m still not grasping this…
I am running the All-in-one installer version so my HA is running in a virtual environment.
If I activate the virtual environment, (sudo su -s /bin/bash homeassistant) my python script works.
However, when I run my script outside the venv, this line generates an error:
import homeassistant.remote as remote
However, I’m not sure what I need to change so that I can execute my python script as part of a command line sensor.
Thanks in advance,
This doesn’t activate the venv, it switches to user homeassistant.
The venv gets activated with . /where/your/venv/lives/bin/activate
EDIT: Should be source /srv/homeassistant/homeassistant_venv/bin/activate
on AIO.
Yep - you are correct…
Activating the homeassistant user doesn’t solve the issue. Activating the venv does.
otherwise I get the following error:
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/pythonscripts/test.py", line 5, in <module>
import homeassistant.remote as remote
ImportError: No module named 'homeassistant'
I guess the real question is, what do I need to change in my command line sensor that I defined as:
- platform: command_line
name: test_sensor_12
command: "/home/homeassistant/.homeassistant/pythonscripts/test.py sensor.test"
Thanks again