From f037ed5c24e54177b20f19a13a7e87b478f77e1b Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 26 Nov 2022 11:11:03 -0500 Subject: [PATCH] Convert Resource class to dataclass --- check_home_assistant_state.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/check_home_assistant_state.py b/check_home_assistant_state.py index a240fd4..f87dba0 100755 --- a/check_home_assistant_state.py +++ b/check_home_assistant_state.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +import dataclasses import logging import sys from urllib.parse import urljoin @@ -11,10 +12,10 @@ import nagiosplugin _log = logging.getLogger("nagiosplugin") -class Batteries(nagiosplugin.Resource): - def __init__(self, url: str, token: str): - self.url = url - self.token = token +@dataclasses.dataclass +class Entities(nagiosplugin.Resource): + url: str + token: str def hass_get(self, endpoint: str) -> requests.Response: headers = { @@ -79,7 +80,7 @@ def main(): args = argp.parse_args() check = nagiosplugin.Check( - Batteries(args.url, args.token), + Entities(args.url, args.token), nagiosplugin.ScalarContext("battery", args.warning, args.critical), ) check.main(args.verbose)