Icke_Bins
(Icke Bins)
February 13, 2020, 9:55pm
1
Hello
i want to get the temperature from another pi. I found some information and a thread from 2017 https://community.home-assistant.io/t/read-data-from-another-pi/30655/2
I have installed the SSH Server addon and configured the ssh-key.
In the configuration i wrote
sensor pi_hole:
- platform: command_line
name: Pi-Hole Temperatur
command: "ssh [email protected] echo $((`cat /sys/class/thermal/thermal_zone0/temp|cut -c1-2`)).$((`cat /sys/class/thermal/thermal_zone0/temp|cut -c3-4`))"
unit_of_measurement: "°C"
But the temperature would not show.
If i type it in the terminal window they show me the temperature without asking the password.
Can anyone help me?
jocnnor
(Jim O'Connor)
February 13, 2020, 10:48pm
2
What’s in the logs?
Probably need to disable pseudo tty allocation
command: "ssh -T [email protected] ..."
tjntomas
(Tomas Jansson)
February 13, 2020, 10:59pm
3
How are you running Home Assistant? Docker, venv etc?
If you are running in a venv, did you activate the venv before configuring the ssh-keys?
If you’re running ssh from Hassio, then take a look at this:
@Grepen
In the beginning I had the same problems as you. The steps and additional options you need are as follow:
Create a folder in your config directory called something like “ssh”
Copy your private keyfile to the newly created folder
SSH into your hassio server and chown the keyfile so only that user has access to it (otherwise your keyfile will be ignored because all users are able to read your private key). Chown command: chown -R hassio:hassio /config/ssh/id_rsa
Lastly change your ssh …
There’s just a few steps to get ssh running smoothly in that context.
void
February 14, 2020, 12:08am
5
hi, i check it like that:
- platform: command_line
name: rpi3_cputemp_ssh
command: "ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] -i /home/homeassistant/.keys/ssh2rpi3 'sudo cat /sys/class/thermal/thermal_zone0/temp' || echo Connection failed."
unit_of_measurement: "°C"
value_template: '{{ value | multiply(0.001) | round(1) }}'
HomeAssistant in a venv
Icke_Bins
(Icke Bins)
February 14, 2020, 9:48pm
6
Thank you all for your reply.
@jocnnor
the log say this
Command failed: ssh [email protected] echo $((`cat /sys/class/thermal/thermal_zone0/temp|cut -c1-2`)).$((`cat /sys/class/thermal/thermal_zone0/temp|cut -c3-4`))
the command with -T also doesnt work
@tjntomas
I downloaded the image from the homepage and installed it on an mircosd and run it on a raspberry pi 4
@Bit-River @void
i havent try it now. i will do this in the next time
Icke_Bins
(Icke Bins)
February 20, 2020, 7:19pm
7
Hello everybody,
@Bit-River
I tried it but at the point with the chown command it says “unknown user/group hassio:hassio”
@void
I tried your commands but it is the same problem
Ah, I got that error too, but it didn’t stop the ssh command from working.
Do you get the same error message when the command line sensor tries to connect?
Icke_Bins
(Icke Bins)
February 20, 2020, 8:59pm
9
i got this error in the log
Command failed: ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] echo $((“cat /sys/class/thermal/thermal_zone0/temp|cut -c1-2”)).$((“cat /sys/class/thermal/thermal_zone0/temp|cut -c3-4”))
Hmmm, is the command part after the IP address surrounded by quotes?
I’m wondering if the ssh part is working, but now the command itself is causing the problem. Sometimes a command with a lot of quotes / special characters won’t work.
Also a good rule of thumb - if there are double-quotes in the command, then use single-quotes to surround it.
So, something like:
ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'echo $((“cat /sys/class/thermal/thermal_zone0/temp|cut -c1-2”)).$((“cat /sys/class/thermal/thermal_zone0/temp|cut -c3-4”))'
An alternative is to have a bash script on the Pi that runs the command, and your command_line sensor calls the script.
So:
ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] '/home/pi/my_temperature_script.sh'
Icke_Bins
(Icke Bins)
February 20, 2020, 9:19pm
11
Here look. if i put the command from my first post in the terminal it works.
i would try it with the bash script.
thank you