Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISC] Removal of openHAB specific MQTT discovery patch #284

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions TheengsGateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"publish_all": 1,
"log_level": "INFO",
"discovery": 1,
"hass_discovery": 1,
"general_presence": 0,
"discovery_topic": "homeassistant",
"discovery_device_name": "TheengsGateway",
Expand Down Expand Up @@ -97,25 +96,19 @@ def parse_args() -> argparse.Namespace:
"-D",
"--discovery",
type=int,
help="Enable(1) or disable(0) MQTT discovery",
help="Enable(1) or disable(0) Home Assistant MQTT discovery",
)
parser.add_argument(
"-Df",
"--discovery_filter",
nargs="+",
help="Device discovery filter list for Home Assistant",
)
parser.add_argument(
"-Dh",
"--hass_discovery",
type=int,
help="Enable(1) or disable(0) Home Assistant MQTT discovery (default: 1)",
help="Device discovery filter list for Home Assistant MQTT discovery",
)
parser.add_argument(
"-Dn",
"--discovery_device_name",
type=str,
help="Device name for Home Assistant",
help="Device name for Home Assistant MQTT discovery",
)
parser.add_argument(
"-Dt",
Expand Down
4 changes: 1 addition & 3 deletions TheengsGateway/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ def publish_device_info(self, pub_device) -> None: # noqa: ANN001
device[
"val_tpl"
] = "{% if value_json.get('unlocked') is true -%}True{%- else -%}False{%- endif %}" # noqa: E501
elif self.configuration["hass_discovery"]:
device["val_tpl"] = "{{ value_json." + k + " | is_defined }}"
else:
device["val_tpl"] = "{{ value_json." + k + " }}"
device["val_tpl"] = "{{ value_json." + k + " | is_defined }}"

config_topic = (
discovery_topic
Expand Down
14 changes: 5 additions & 9 deletions docs/use/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ usage: TheengsGateway [-h] [-a ADAPTER] [-b BLE] [-bk ADDRESS [BINDKEY ...]]
[-bl ADDRESS [ADDRESS ...]]
[-c CONFIG] [-D DISCOVERY]
[-Df DISCOVERY_FILTER [DISCOVERY_FILTER ...]]
[-Dh HASS_DISCOVERY] [-Dn DISCOVERY_DEVICE_NAME]
[-Dn DISCOVERY_DEVICE_NAME]
[-Dt DISCOVERY_TOPIC] [-Gp GENERAL_PRESENCE] [-H HOST]
[-id ADDRESS [IRK ...]]
[-Lt LWT_TOPIC] [-ll {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
Expand All @@ -120,14 +120,11 @@ options:
-c CONFIG, --config CONFIG
Path to the configuration file (default: ~/theengsgw.conf)
-D DISCOVERY, --discovery DISCOVERY
Enable(1) or disable(0) MQTT discovery
-Df DISCOVERY_FILTER [DISCOVERY_FILTER ...], --discovery_filter DISCOVERY_FILTER [DISCOVERY_FILTER ...]
Device discovery filter list for Home Assistant
-Dh HASS_DISCOVERY, --hass_discovery HASS_DISCOVERY
Enable(1) or disable(0) Home Assistant MQTT discovery
(default: 1)
-Df DISCOVERY_FILTER [DISCOVERY_FILTER ...], --discovery_filter DISCOVERY_FILTER [DISCOVERY_FILTER ...]
Device discovery filter list for Home Assistant MQTT discovery
-Dn DISCOVERY_DEVICE_NAME, --discovery_device_name DISCOVERY_DEVICE_NAME
Device name for Home Assistant
Device name for Home Assistant MQTT discovery
-Dt DISCOVERY_TOPIC, --discovery_topic DISCOVERY_TOPIC
MQTT Discovery topic
-Gp GENERAL_PRESENCE, --general_presence GENERAL_PRESENCE
Expand Down Expand Up @@ -252,7 +249,6 @@ By default Theengs Gateway listens to `home/+/BTtoMQTT/undecoded`, if you have s
## Home Assistant auto discovery
If enabled (default), decoded devices publish their configuration to Home Assistant so the latter can discover them.
- You can enable/disable this with the `-D` or `--discovery` command line argument with a value of 1 (enable) or 0 (disable).
- If you want to use Home Assistant discovery with other home automation gateways such as openHAB, set `-Dh` or `--hass_discovery` to 0 (disable).
- You can set the discovery topic with the `-Dt` or `--discovery_topic` command line argument.
- You can set the discovery name with the `-Dn` or `--discovery_device_name` command line argument.
- You can filter devices from discovery with the `-Df` or `--discovery_filter` argument which takes a list of device model ID to filter.
Expand All @@ -262,7 +258,7 @@ If enabled (default), decoded devices publish their configuration to Home Assist
The `IBEACON` and random MAC devices (`APPLE`*, `MS-CDP` and `GAEN`) aren't discovered as their addresses (IDs) change over time resulting in multiple discoveries.

:::tip * INFO
Home Assistant discovers an Apple Watch, iPhone, or iPad if you've configured their Identity MAC address and IRK.
Home Assistant discovers an Apple Watch, iPhone, iPad or AirPods if you've configured their Identity MAC address and IRK.
:::

<!-- vale Google.Acronyms = YES -->
Expand Down