diff --git a/README.md b/README.md index 0cef885..13ef308 100644 --- a/README.md +++ b/README.md @@ -92,3 +92,19 @@ The following attributes are set on `switch` entities: | `sprinkler_type` | `string` | The configured type of sprinker. | | `image_url` | `string` | The url to zone image | | `started_watering_station_at` | `string` | The timestamp the zone started watering. | + +# Debugging + +To debug this integration and provide device integration for future improvements, please enable debugging in Home Assistant's `configuration.yaml` + +```yaml +logger: + logs: + custom_components.bhyve: debug + +bhyve: + username: !secret bhyve_username + password: !secret bhyve_password + packet_dump: true # Save all websocket event data to a file + conf_dir: "" # Storage directory for packet dump file. Usually not needed, defaults to hass_config_dir/.bhyve +``` diff --git a/custom_components/bhyve/__init__.py b/custom_components/bhyve/__init__.py index 6af1190..b4ade9d 100644 --- a/custom_components/bhyve/__init__.py +++ b/custom_components/bhyve/__init__.py @@ -37,10 +37,8 @@ DATA_CONFIG = "config" -DEFAULT_SOCKET_MIN_RETRY = 15 -DEFAULT_PACKET_DUMP = True +DEFAULT_PACKET_DUMP = False DEFAULT_CONF_DIR = "" -DEFAULT_WATCHDOG_SECONDS = 5 * 60 CONFIG_SCHEMA = vol.Schema( { @@ -108,7 +106,13 @@ async def async_update_callback(data): ) await bhyve.login() - await bhyve.devices + devices = await bhyve.devices + for device in devices: + device["address"] = "REDACTED" + device["full_location"] = "REDACTED" + device["location"] = "REDACTED" + + _LOGGER.debug("Devices: {}".format(devices)) hass.data[DOMAIN] = bhyve except WebsocketError as err: diff --git a/custom_components/bhyve/const.py b/custom_components/bhyve/const.py index 65bbcbe..092ab3a 100644 --- a/custom_components/bhyve/const.py +++ b/custom_components/bhyve/const.py @@ -3,7 +3,7 @@ MANUFACTURER = "Orbit BHyve" CONF_ATTRIBUTION = "Data provided by api.orbitbhyve.com" -CONF_CONF_DIR = "" +CONF_CONF_DIR = "conf_dir" CONF_PACKET_DUMP = "packet_dump" ATTR_LAST_DATA = "last_data" diff --git a/custom_components/bhyve/pybhyve/client.py b/custom_components/bhyve/pybhyve/client.py index 1cd2951..7ec7850 100644 --- a/custom_components/bhyve/pybhyve/client.py +++ b/custom_components/bhyve/pybhyve/client.py @@ -75,7 +75,6 @@ async def _refresh_devices(self): for device in self._devices: deviceName = device.get("name") deviceType = device.get("type") - _LOGGER.info("Found device: {} [{}]".format(deviceType, deviceName)) self._last_poll = now diff --git a/info.md b/info.md index bc79e29..13ef308 100644 --- a/info.md +++ b/info.md @@ -1,11 +1,22 @@ # bhyve-home-assistant -BHyve component for [Home Assistant](https://www.home-assistant.io/). +Orbit BHyve component for [Home Assistant](https://www.home-assistant.io/). + +If this integration has been useful to you, please consider chipping in and buying me a coffee! + +Buy Me A Coffee ## Supported Entities -* `sensor` for measuring battery levels of `sprinkler_timer` devices -* `binary_sensor` for tracking rain/weather delays -* `switch` for turning a zone on/off + +- `sensor` for measuring battery levels of `sprinkler_timer` devices +- `binary_sensor` for tracking rain/weather delays +- `switch` for turning a zone on/off + +## Installation + +Recommended installation is via HACS. + +[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs) ## Configuration @@ -23,3 +34,77 @@ binary_sensor: switch: - platform: bhyve ``` + +## Sensor Entities + +`sensor` entities are automatically created for any device which has a battery level to report. + +## Binary Sensor Entities + +A **Rain Delay** `binary sensor` will be created for each discovered `sprinkler_timer` device. This entity will be **on** whenever BHyve reports that a device's watering schedule will be delayed due to weather conditions. + +### Rain Delay Attributes + +The following attributes are set on `binary_sensor.rain_delay_*` entities, if the sensor is on: + +| Attribute | Type | Notes | +| -------------- | -------- | ----------------------------------------------------------------------------------------- | +| `cause` | `string` | Why a delay was put in place. Values seen: `auto`. May be empty. | +| `delay` | `number` | The number of hours the delay is in place. NB: This is hours from `started_at` attribute. | +| `weather_type` | `string` | The reported cause of the weather delay. Values seen: `wind`, `rain`. May be empty. | +| `started_at` | `string` | The timestamp the delay was put in place. | + +### Rain Delay Template Sensors + +It is possible to create template sensors from these attributes. Here are two examples which provide a sensor to report: + +1. When the current rain delay for a device is ending +2. The number of hours remaining on the current rain delay + +```yaml +sensor: + - platform: template + sensors: + rain_delay_lawn_finishing: + friendly_name: "Rain Delay Lawn Finishing" + value_template: "{{(as_timestamp(state_attr('binary_sensor.rain_delay_lawn', 'started_at')) + state_attr('binary_sensor.rain_delay_lawn', 'delay') * 3600) | timestamp_local }}" + + rain_delay_lawn_remaining: + friendly_name: "Rain Delay Lawn Remaining" + unit_of_measurement: "h" + value_template: "{{((as_timestamp(state_attr('binary_sensor.rain_delay_lawn', 'started_at')) + state_attr('binary_sensor.rain_delay_lawn', 'delay') * 3600 - as_timestamp(now())) / 3600) | round(0) }}" +``` + +## Switch Entities + +A `switch` entity is created for each zones of a `sprinkler_timer` device. This switch enables starting/stopping irrigation of a zone. + +Turning on the switch will enable watering of the zone for the amount of time configured in the BHyve app. + +### Switch Attributes + +The following attributes are set on `switch` entities: + +| Attribute | Type | Notes | +| ----------------------------- | --------- | -------------------------------------------------------------------- | +| `manual_preset_runtime` | `number` | The number of seconds to run zone watering when switch is turned on. | +| `smart_watering_enabled` | `boolean` | True if the zone has a smart water schedule enabled. | +| `sprinkler_type` | `string` | The configured type of sprinker. | +| `image_url` | `string` | The url to zone image | +| `started_watering_station_at` | `string` | The timestamp the zone started watering. | + +# Debugging + +To debug this integration and provide device integration for future improvements, please enable debugging in Home Assistant's `configuration.yaml` + +```yaml +logger: + logs: + custom_components.bhyve: debug + +bhyve: + username: !secret bhyve_username + password: !secret bhyve_password + packet_dump: true # Save all websocket event data to a file + conf_dir: "" # Storage directory for packet dump file. Usually not needed, defaults to hass_config_dir/.bhyve +```