#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.


def inventory_tplink_poe_summary(info):
    if info and info[0][0] != "0":
        return [(None, {})]


def check_tplink_poe_summary(_no_item, params, info):
    deci_watt = float(info[0][0])
    watt = deci_watt / 10
    return check_levels(watt, "power", params, unit="Watt")


check_info["tplink_poe_summary"] = {
    "check_function": check_tplink_poe_summary,
    "inventory_function": inventory_tplink_poe_summary,
    "service_description": "POE Power",
    "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.11863.5"),
    "snmp_info": (".1.3.6.1.4.1.11863.6.56.1.1.1", ["3"]),
    "has_perfdata": True,
    "group": "epower_single",
}
