Sensor ssh


I am currently using a sensor to retrieve a password from a text file on a Linux server:


    platform: command_line
    name: MDP
    unique_id: sensor.mdp
    command: "ssh -i /config/.ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] -p 66 'cat /var/www/html/upload/mdp'"

The problem is that this sensor will connect to the server every minute to retrieve the value.

I think this sensor system is not suitable.

How can I retrieve this value on demand, for example when I press a button?

I have another SSH command to generate the password, but I have never been able to retrieve this value and store it on Home Assistant, which is why I use the sensor…

If anyone has a better idea.

Thank you

Set the scan_interval option to something huge (years).

Use the homeassistant.update_entity service as a button tap action to update it when the button is tapped.

Your sensor will still update once every time home assistant is restarted though.

@tom_l Ohh, ok it’s perfect !

Can I make scan_interval in minutes or I must use seconds ?

You have to use seconds.

31,536,000 is one year (don’t put the commas in).