For those of you have taken on the DIY project MagicMirror and have tried to use a PIR sensor with a raspberry pi you might notice that when WiFi is active your sensor is constantly in a high state due to RF interference. A solution to fix is to either shield the PIR sensor with anti static bag or move the sensor about 10-15 or so feet away.
Neither of these where a suitable option for me plus i already have a PIR sensor working by MQTT and HA anyways. To combine the two, I simply just used shell_command and installed the following
sudo apt-get install sshpass
This will allow you to login To SSH Server and Provide SSH Password Using A Shell Script… Next you need to creating a shell_command in your config like so:
Tip:Before any of this will work you need to run the command once manually to accept the SSH Key. To do this you need to be in the HA virtualenv as HA user when venv is activated, Other wise none of this will work.
The PIR is actually connected to a different Pi, that talks to my Home Assistant instance on a separate server. I have a Pi Zero connected to a TV running magic mirror that’s always on, but the TV is connected to a LightWaveRF remote controlled socket. When PIR is ON on the Pi, it sends the status to HA via API, HA turns the socket on via rfxtrx.
the PIR is powered via +5V and GND on the Pi, data pin connected to any GPIO…
@Andrew_Lozoya thanks for this but sshpass doesn’t work for me at all. I haven’t configured it with my HA as I am just trying it out i.e. trying to send some command from my NUC to my raspberry pi but nothing happens. i.e. I dont see anything.
However when I use it with the command line switch on HA. It doesnt work and throws an error saying: ERROR (SyncWorker_7) [homeassistant.components.switch.command_line] Command failed: ssh [email protected] vcgencmd display_power 0
Try saving the command as a script on the Rpi and call the script from NUC. I recall having problems reliably turning HDMI signal off and back on with the Rpi and a computer monitor.
After thinking things over I switched to a 28" TV (controlled by IR remote) as it opens additional options (by the use of multiple HDMI ports and speakers).
I have two NodeMCU with OpenMQTT (I think I could’ve gone with only one but at that time there were some issues with the sketch I was using) that take care of most of the “smart” parts:
IR blaster, to send commands (discrete on/off, volume adjustment, brightness, source selection) to the TV;