From 819ff2ed97b45a4caacdbf5acfba0244259f1231 Mon Sep 17 00:00:00 2001 From: Antoine Van Elstraete Date: Sat, 23 Aug 2025 20:21:24 +0200 Subject: [PATCH] Ajout des interfaces LAN et Starlink --- snmp2mqtt.py | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/snmp2mqtt.py b/snmp2mqtt.py index 0038000..a6abf03 100755 --- a/snmp2mqtt.py +++ b/snmp2mqtt.py @@ -62,9 +62,9 @@ async def get_snmp(req): logging.debug(f"{req['device_name']} {oid['name']} => {oid['type'](varBind[1])}") if oid['type'] == bool: if bool(varBind[1]): - data.update({oid["name"]: "on"}) + data.update({oid["name"]: "ON"}) else: - data.update({oid["name"]: "off"}) + data.update({oid["name"]: "OFF"}) else: data.update({oid["name"]: oid["type"](varBind[1])}) logging.debug(f"JSON : {json.dumps(data)}") @@ -113,7 +113,7 @@ def send_to_mqtt(): state_topic = config['state_topic'] while True: try: - publish(config_topic, client, config, True, 2) + publish(config_topic, client, config, True, 0) logging.info(f"{config_topic} -> {config}") except Exception as e: logging.error(e) @@ -152,7 +152,48 @@ req = { "type": bool, "HA_device_class": "connectivity", "HA_platform": "binary_sensor", + }, + {"name": "lan_bridge_in", + "oid": ".1.3.6.1.2.1.2.2.1.10.6", + "type": int, + "HA_device_class": "data_size", + "HA_platform": "sensor", + "HA_unit": "bit" + }, + {"name": "lan_bridge_out", + "oid": ".1.3.6.1.2.1.2.2.1.16.6", + "type": int, + "HA_device_class": "data_size", + "HA_platform": "sensor", + "HA_unit": "bit" + }, + {"name": "lan_bridge_status", + "oid": ".1.3.6.1.2.1.2.2.1.8.6", + "type": bool, + "HA_device_class": "connectivity", + "HA_platform": "binary_sensor", + }, + {"name": "starlink_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": "starlink_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": "starlink_status", + "oid": ".1.3.6.1.2.1.2.2.1.8.1", + "type": bool, + "HA_device_class": "connectivity", + "HA_platform": "binary_sensor", } + ] }