From affeeaff7d8e63191258ba6ccfad90c2da44ae49 Mon Sep 17 00:00:00 2001 From: Seb Ruiz Date: Sat, 27 May 2023 21:00:33 +1000 Subject: [PATCH] chore: fix formatting --- custom_components/bhyve/binary_sensor.py | 4 +++- custom_components/bhyve/switch.py | 3 +-- debug/debug.py | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) mode change 100644 => 100755 debug/debug.py diff --git a/custom_components/bhyve/binary_sensor.py b/custom_components/bhyve/binary_sensor.py index 8f53d8a..86e13a6 100644 --- a/custom_components/bhyve/binary_sensor.py +++ b/custom_components/bhyve/binary_sensor.py @@ -39,7 +39,9 @@ def __init__(self, hass, bhyve, device): """Initialize the sensor.""" name = "{} flood sensor".format(device.get("name")) _LOGGER.info("Creating flood sensor: %s", name) - super().__init__(hass, bhyve, device, name, "water", BinarySensorDeviceClass.MOISTURE) + super().__init__( + hass, bhyve, device, name, "water", BinarySensorDeviceClass.MOISTURE + ) def _setup(self, device): self._available = device.get("is_connected", False) diff --git a/custom_components/bhyve/switch.py b/custom_components/bhyve/switch.py index 8a9ebba..7de1df6 100644 --- a/custom_components/bhyve/switch.py +++ b/custom_components/bhyve/switch.py @@ -150,7 +150,6 @@ async def async_setup_entry( device_id = device.get("id") device_by_id[device_id] = device if device.get("type") == DEVICE_SPRINKLER: - if not device.get("status"): _LOGGER.warning( "Unable to configure device %s: the 'status' attribute is missing. Has it been paired with the wifi hub?", @@ -280,7 +279,7 @@ async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" await self._set_state(False) - + async def start_program(self): """Begins running a program.""" program_payload = self._program["program"] diff --git a/debug/debug.py b/debug/debug.py old mode 100644 new mode 100755 index fc45918..9852f2a --- a/debug/debug.py +++ b/debug/debug.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # Script utility to debug device/program info from logs import json @@ -14,7 +15,7 @@ diagnostics_json = os.path.join(script_dir, folder + "/diagnostics.json") -with open(diagnostics_json) as diagnosticsFile: +with open(diagnostics_json, mode="r", encoding="utf8") as diagnosticsFile: diagnostics = json.load(diagnosticsFile) diagnosticsFile.close() @@ -22,16 +23,17 @@ if device.get("type") == "bridge": continue - name = device.get("name") + name = device.get("name", "Unknown Name") print("") if device.get("type") == "sprinkler_timer": zones = device.get("zones") print(f"{'Sprinkler':>10}: {name}") - print(f"{'Zones':>10}: ({len(zones)})") + print(f"{'Battery':>10}: {device.get('battery').get('percent')}%") + print(f"{'Zones':>10}: {len(zones)}") for zone in device.get("zones"): - zn = zone.get("name") - print(f"{zn:<12}: {zn}") + zn = zone.get("name", "Unknown Zone") + print(f" - {zn}") if device.get("type") == "flood_sensor": print("Flood sensor:")