broesie
(Ryoen Deprouw)
February 9, 2017, 4:32pm
1
I get errors when I use a command line sensor to show the current version of my Hass.
17-02-09 05:06:42 ERROR (Thread-7) [homeassistant.components.sensor.command_line] Command failed: python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
My setup is:
- platform: command_line
name: "HASS Release"
command: python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
I copied that from the page of the command sensor, they use this example…
Anyway it does not work…
rpitera
(Robert Pitera)
February 9, 2017, 4:36pm
2
I use these two sensors to track the current and installed versions:
- platform: command_line
command: python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
name: Current HA Version
- platform: command_line
name: Installed version
command: "/srv/hass/hass_venv/bin/hass --version"
And they work for me.
Tinkerer
(aka DubhAd on GitHub)
February 9, 2017, 4:36pm
3
How did you install HA? Do you have python3 installed - if you type which python3
, what do you get?
I’ve got the same command, and it works for me. I used the AIO installer on my Pi.
- platform: command_line
command: python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
broesie
(Ryoen Deprouw)
February 9, 2017, 4:37pm
4
Tinkerer:
How did you install HA?
When I installed HA a while ago, I installed it also by using the AIO
rpitera
(Robert Pitera)
February 9, 2017, 4:39pm
5
Remember that you may have one version when running as Pi or Root and another while running as the HA user in the virtual environment.
In venv as hass, I am running Python 3.4.2 but as the Pi user in a regular session I am running Python 2.x.
I installed via a pre-December 2016 version of the AIO installer.
broesie
(Ryoen Deprouw)
February 9, 2017, 4:42pm
6
I also installed a pre december 2016 version…
rpitera
(Robert Pitera)
February 9, 2017, 4:43pm
7
Try copying my two sensors and running with them and see if they show up without an error.
broesie
(Ryoen Deprouw)
February 9, 2017, 4:45pm
8
Seems this is working:
- platform: command_line
name: Installed version
command: "/srv/hass/hass_venv/bin/hass --version"
The other with command the following command gives errors
python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
rpitera
(Robert Pitera)
February 9, 2017, 4:59pm
9
It’s odd because I can do this from the command line as Pi and I get a proper version response whether I use python3 or python.
What do you get when you run:
python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
from the command line?
broesie
(Ryoen Deprouw)
February 9, 2017, 5:01pm
10
I got the right value in putty and in Hass frontend, but still got errors in the log file…
rpitera
(Robert Pitera)
February 9, 2017, 5:06pm
11
I’m kinda stumped at this point. If you’re getting the right version number, then there’s no problems with getting to the URL, so that can be ruled out.
The only other thing I can think of is logging in as the HA user, activating the virtual environment and running the same command to see if you get a different result.
broesie
(Ryoen Deprouw)
February 9, 2017, 5:11pm
12
rpitera:
I’m kinda stumped at this point. If you’re getting the right version number, then there’s no problems with getting to the URL, so that can be ruled out.
The only other thing I can think of is logging in as the HA user, activating the virtual environment and running the same command to see if you get a different result.
When logging in as hass user and the evironment, I also got the right value, without errors… So the command seems okay, but I dont understand as well, why I got some errors in my log…
rpitera
(Robert Pitera)
February 9, 2017, 5:13pm
13
Is it the same error in your first post?
broesie
(Ryoen Deprouw)
February 9, 2017, 5:16pm
14
When I directly run the command, I dont get errors, but in the logfiles, it showed that error… very strange…
However, the only thing I can do is, without errors, using the command: /srv/hass/hass_venv/bin/hass --version
I replaced already my sensor with that command…
rpitera
(Robert Pitera)
February 9, 2017, 5:19pm
15
Sorry I can’t come up with anything else, but maybe the troubleshooting we did will lead someone else to an answer.
1 Like
broesie
(Ryoen Deprouw)
February 9, 2017, 5:21pm
16
Anyway, it’s good that we have a workaround for this
1 Like
rpitera
(Robert Pitera)
February 9, 2017, 6:00pm
17
I’m glad I could help in some way.
Good day, this command no longer works in Hassbian 1.3
Any suggestions?
Thank you
Found the solution need to sudo pip3 install requests
1 Like