geoced
(Geoced)
August 14, 2023, 6:33pm
1
Hi there,
I have copy-pasted the “Details about the upstream Home Assistant release” example from the official help page of the Command Line integration , but it throws an error in the logs:
2023-08-14 19:54:04.566 ERROR (SyncWorker_9) [homeassistant.components.command_line.utils] Command failed (with return code 1): python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/hom
eassistant/json').json()['info']['version'])"
The same command returns the correct version number when run from my python 3.11 venv.
I’m on HA core 2023.8.2
This used to work before the command line breaking change introduced in 2023.6.
Here is my command_lines.yaml file:
- sensor:
command: python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
name: Latest HA release
scan_interval: 3600
unique_id: '1657007051'
Any idea what I’m doing wrong ? Or is it a bug ?
rccoleman
(Rob Coleman)
August 14, 2023, 8:29pm
2
I just put exactly what’s in the docs in my configuration.yaml
and it worked fine. How are you including your command_lines.yaml
file?
geoced
(Geoced)
August 14, 2023, 9:51pm
3
Here are the first few lines of my configuration.yaml file:
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include templates.yaml
sensor: !include sensors.yaml
command_line: !include command_lines.yaml
rccoleman
(Rob Coleman)
August 14, 2023, 10:08pm
4
No idea, then. I created command_lines.yaml
, included it as you did, restarted HA, and it works fine for me. Perhaps you have some DNS issue preventing HA from accessing that site.
geoced
(Geoced)
August 15, 2023, 1:08pm
5
The command works fine when running inside the same Python 3.11 venv hosting home-assistant:
me@raspberrypi:/home/homeassistant/.homeassistant $ sudo -u homeassistant -H -s
homeassistant@raspberrypi:~/.homeassistant $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@raspberrypi:~/.homeassistant $ python3 -c "import requests; print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
2023.8.2
This tells me that it’s not a network issue, but a software issue.
petro
(Petro)
August 15, 2023, 1:39pm
6
Just use a rest sensor, it’ll do the same thing, but you can get everything from the response and you can built multiple sensors from a single rest endpoint.
geoced
(Geoced)
August 15, 2023, 5:28pm
7
I never used that one, but it worked immediately ! Thanks! BTW, I just noticed that the Version integration does the same thing…