Cette modification introduit la possibilité d'appliquer une opération mathématique simple (addition, soustraction, multiplication, division) sur les valeurs SNMP récupérées. L'utilisateur peut désormais définir une clé 'operation' dans la configuration d'un OID (par exemple, 'value / 1000') pour normaliser les données avant leur envoi à MQTT. La documentation dans `config.yaml` a été mise à jour avec un exemple.
69 lines
2.4 KiB
YAML
69 lines
2.4 KiB
YAML
# SNMP2MQTT Configuration File
|
|
# This file contains the configuration for the SNMP to MQTT bridge
|
|
|
|
# MQTT Broker Configuration
|
|
mqtt:
|
|
broker: "IP or FQDN"
|
|
port: 1883
|
|
user: "USER"
|
|
password: "PASSWORD"
|
|
|
|
# Optional: Sleep interval between SNMP polls (default: 2 seconds)
|
|
sleep_interval: 2
|
|
|
|
# Device Configurations
|
|
# You can define multiple devices here. Each device will be monitored independently.
|
|
devices:
|
|
# Device name (used for MQTT topics and Home Assistant device identification)
|
|
mikrotik_hex:
|
|
ip: "IP"
|
|
snmp_community: "public"
|
|
oids:
|
|
# example interface index 1
|
|
- name: "if1_in"
|
|
oid: ".1.3.6.1.2.1.2.2.1.10.1"
|
|
type: "int"
|
|
HA_device_class: "data_size"
|
|
HA_platform: "sensor"
|
|
HA_unit: "bit"
|
|
|
|
- name: "if1_out"
|
|
oid: ".1.3.6.1.2.1.2.2.1.16.1"
|
|
type: "int"
|
|
HA_device_class: "data_size"
|
|
HA_platform: "sensor"
|
|
HA_unit: "bit"
|
|
|
|
- name: "if1_status"
|
|
oid: ".1.3.6.1.2.1.2.2.1.8.1"
|
|
type: "bool"
|
|
HA_device_class: "connectivity"
|
|
HA_platform: "binary_sensor"
|
|
|
|
# Example of a temperature sensor that returns the value in millidegrees.
|
|
# The 'operation' key allows performing a simple calculation.
|
|
# The placeholder 'value' will be replaced by the SNMP value.
|
|
# - name: "temperature"
|
|
# oid: ".1.3.6.1.4.1.XXXX.1.1.1.5.1.3.1" # Example OID
|
|
# type: "int"
|
|
# operation: "value / 1000"
|
|
# HA_device_class: "temperature"
|
|
# HA_platform: "sensor"
|
|
# HA_unit: "°C"
|
|
|
|
# OID Configuration Reference:
|
|
# - name: Unique identifier for this metric (used in MQTT topics and Home Assistant)
|
|
# - oid: SNMP Object Identifier
|
|
# - type: Python type for value conversion ("int", "bool", "str")
|
|
# - HA_device_class: Home Assistant device class for proper icon/categorization
|
|
# Common classes: data_size, connectivity, power_factor, temperature, etc.
|
|
# - HA_platform: Home Assistant platform type ("sensor", "binary_sensor")
|
|
# - HA_unit: (optional) Unit of measurement for the sensor
|
|
# Common units: "bit", "byte", "%", "°C", "°F", etc.
|
|
|
|
# Common SNMP OIDs for network interfaces:
|
|
# - .1.3.6.1.2.1.2.2.1.10.X = Incoming bytes on interface X
|
|
# - .1.3.6.1.2.1.2.2.1.16.X = Outgoing bytes on interface X
|
|
# - .1.3.6.1.2.1.2.2.1.8.X = Interface operational status (1=up, 2=down)
|
|
# - .1.3.6.1.2.1.2.2.1.2.X = Interface description
|