#!/usr/bin/python
import requests
import sys
import re

# Define version at the top for easy modification
VERSION = "2025-08-19"

# Set DEBUG to 1 to enable debug output, 0 to disable
DEBUG = 0

def get_rssi(ip_address):
url = f'http://{ip_address}/rpc/Shelly.GetStatus'
try:
response = requests.get(url)
if response.status_code == 200:
data = response.json()
if DEBUG:
print("=== Debug: Raw JSON response ===")
print(data)
print("=== End of response ===")
# Depending on Shelly model, Wi-Fi info may be under different keys
wifi_info = data.get('wifi', {})
rssi_value = wifi_info.get('rssi')
ssid_value = wifi_info.get('ssid')
bssid_value = wifi_info.get('bssid')
if rssi_value is not None:
print("<<<check_mk>>>")
print(f"Version: {VERSION}")
print("<<<local>>>")
print(f"0 shellyplus1-wlan rssi={rssi_value} RSSI value is {rssi_value}dBm, SSID is {ssid_value}, BSSID is {bssid_value}")
else:
print("RSSI info not found in the device status.")
else:
print(f"Failed to retrieve /status from {ip_address}, status code: {response.status_code}")
except Exception as e:
print(f"Error accessing {ip_address}: {e}")

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python shellyPlus1.py <IP_ADDRESS>")
else:
get_rssi(sys.argv[1])

computer2know :: thank you for your visit :: have a nice day :: © 2025