I am currently migrating a homeassistant installation (without virtualenv) into a new virtualenv one. I followed the corresponding guide on the website except using the defaut user pi instead of an own system account for homeassistant. After copying my old configuration everything worked out of the box except nmap presence detection, command line sensors and switches and shell scripts. The old config:
The command line sensor reads the first line of a txt file:
- platform: command_line
name: foo
unit_of_measurement: "bar"
scan_interval: 21600
command: head -1 /home/pi/data.txt | tail -1
The command line switch checks state of my PS4 and uses netcat and ps4-waker:
- platform: command_line
switches:
playstation4:
command_on: 'sudo ps4-waker -c /home/pi/.homeassistant/ps4-wake.credentials.json'
command_off: 'sudo ps4-waker standby -c /home/pi/.homeassistant/ps4-wake.credentials.json'
command_state: 'nc -z -w 5 ps4-2d31a 9295'
friendly_name: "Playstation 4"
The shell commands are triggered by an input select from the gui:
raspi_reboot: "sudo reboot"
raspi_shutdown: "sudo shutdown -h now"
When looking into /var/log/daemon.log
the command line switch throws the following error: hass[2687]: /bin/sh: 1: nc: not found
. Netcat is installed but cannot be found from venv. I guess it’s the same problem with nmap
, tail
and head
.
Before moving into virtualenv all these commands executed fine. I have two questions:
- In what way do I have to change them to make them work in a virtual environment?
- Is it possible to use
sudo
commands from venv likesudo reboot
?