AlexxIT / PythonScriptsPro

Advanced version of python scripts for Home Assistant without limits
https://github.com/AlexxIT/Blog
117 stars 17 forks source link

Sensor is not working #33

Closed icq5564476 closed 3 months ago

icq5564476 commented 3 months ago

2024-08-28 19:26:38.676 WARNING (ImportExecutor_0) [py.warnings] /usr/local/lib/python3.12/site-packages/paramiko/pkey.py:100: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0. 2024-08-28 19:26:39.237 WARNING (ImportExecutor_0) [py.warnings] /usr/local/lib/python3.12/site-packages/paramiko/transport.py:258: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.

Эта ошибка возникла в пользовательской интеграции.

Регистратор: custom_components.python_script.sensor Источник: custom_components/python_script/sensor.py:66 интеграция: Python Scripts Pro (документация, проблемы) Первое сообщение: 19:26:39 (18 сообщений) Последнее сообщение: 19:43:39

Error update WD MBL температура диска Traceback (most recent call last): File "/config/custom_components/python_script/sensor.py", line 66, in update exec(self.code) File "", line 3, in NameError: name 'data' is not defined

remote_ssh_command.py:

from paramiko import SSHClient, AutoAddPolicy

host = data.get("host")
port = data.get("port")
username = data.get("username")
password = data.get("password")
command = data.get("command")

client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(host, port, username, password)
stdin, stdout, stderr = client.exec_command(command)
resp = stdout.read()
stderr.read()
client.close()

logger.info(f"SSH response:\n{ resp.decode() }")

My custom sensor:

  sensor:
    - platform: python_script
      name: WD MBL температура диска
      unique_id: "wdmbl_temp"
      scan_interval: "00:01:00" # optional, default: 30s
      unit_of_measurement: "°C"
      icon: mdi:nas
      file: scripts/remote_ssh_command.py
      host: !secret wdmbl_host
      port: !secret wdmbl_port
      username: wdmbl_user
      password: !secret wdmbl_password
      command: >
        smartctl -a /dev/sda | grep -i temperature | awk '{print $10}'