Ajout des interfaces LAN et Starlink
This commit is contained in:
47
snmp2mqtt.py
47
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",
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user