14 Commits
0.1.0 ... 0.1.4

Author SHA1 Message Date
adfe5dfe9d custom_components/whatsapp_bridge_integration/manifest.json aktualisiert 2026-04-14 13:29:15 +00:00
037cd9c9c7 custom_components/whatsapp_bridge_integration/__init__.py aktualisiert 2026-04-14 13:28:19 +00:00
498c059aa8 custom_components/whatsapp_bridge_integration/manifest.json aktualisiert 2026-04-14 13:24:38 +00:00
dbdf987501 custom_components/whatsapp_bridge_integration/__init__.py aktualisiert 2026-04-14 13:24:24 +00:00
370e33da7c custom_components/whatsapp_bridge_integration/services.yaml aktualisiert 2026-04-14 13:24:10 +00:00
5d5971ece0 custom_components/whatsapp_bridge_integration/manifest.json aktualisiert 2026-04-14 13:15:31 +00:00
8b9aacfefb custom_components/whatsapp_bridge_integration/__init__.py aktualisiert 2026-04-14 13:15:02 +00:00
c0800ce2bb custom_components/whatsapp_bridge_integration/config_flow.py aktualisiert 2026-04-14 13:14:45 +00:00
43b4c747e5 custom_components/whatsapp_bridge_integration/services.yaml hinzugefügt 2026-04-14 13:14:25 +00:00
61f36c7db7 custom_components/whatsapp_bridge_integration/__init__.py aktualisiert 2026-04-14 13:02:03 +00:00
9981adf5ac custom_components/whatsapp_bridge_integration/config_flow.py hinzugefügt 2026-04-14 13:01:48 +00:00
6b927b7e20 custom_components/whatsapp_bridge_integration/manifest.json aktualisiert 2026-04-14 13:01:29 +00:00
5122d59535 custom_components/whatsapp_bridge_integration/const.py hinzugefügt 2026-04-14 13:01:06 +00:00
f7240b4eb3 README.md aktualisiert 2026-04-14 12:35:23 +00:00
6 changed files with 145 additions and 37 deletions

View File

@@ -31,3 +31,32 @@ action: whatsapp_bridge_integration.send_message
data: data:
number: "491701234567" number: "491701234567"
message: "The washing machine is finished! 🧺" message: "The washing machine is finished! 🧺"
```
### Use in Node-RED
Add a Call Service (or Action) node.
Domain: whatsapp_bridge_integration
Service: send_message
Data:
```JSON
{
"number": "491701234567",
"message": "{{payload}}"
}
```
## 👥 Multi-Account Support (Coming Soon)
We are currently working on a UI-based configuration flow so you can save "Account Aliases" (like "Dad", "Work", "Security") and select them from a dropdown menu without typing the phone number every time.
##⚠️ Important Notes
Phone Numbers: Always use the international format without + or 00 (e.g., 49... for Germany).
Local Network: The integration communicates locally with the Add-on on port 3000.
Developed by Bahmcloud
---

View File

@@ -1,47 +1,64 @@
import logging import logging
import requests import requests
import voluptuous as vol import voluptuous as vol
from homeassistant.helpers import config_validation as cv from homeassistant.core import HomeAssistant, ServiceCall
from .const import DOMAIN, CONF_PHONE_NUMBER
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DOMAIN = "whatsapp_bridge_custom" async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the WhatsApp Bridge component."""
# Diese Funktion muss existieren, auch wenn sie nur True zurückgibt
return True
# Definition der Service-Parameter async def async_setup_entry(hass: HomeAssistant, entry):
SERVICE_SEND_MESSAGE = "send_message" """Set up WhatsApp Bridge from a config entry."""
ATTR_NUMBER = "number"
ATTR_MESSAGE = "message"
SERVICE_SCHEMA = vol.Schema({ # Registriere den Dienst nur einmal
vol.Required(ATTR_NUMBER): cv.string, if not hass.services.has_service(DOMAIN, "send_message"):
vol.Required(ATTR_MESSAGE): cv.string,
})
async def async_setup(hass, config): async def handle_send_message(call: ServiceCall):
"""Set up the WhatsApp Bridge integration.""" message = call.data.get("message")
recipient = call.data.get("recipient")
use_manual = call.data.get("use_manual_number", False)
target_number = call.data.get("number")
def send_whatsapp_msg(call): entries = hass.config_entries.async_entries(DOMAIN)
"""Dienst-Funktion: Nachricht an das Add-on senden.""" targets = []
number = call.data.get(ATTR_NUMBER)
message = call.data.get(ATTR_MESSAGE)
# Die interne URL zum Add-on (standardmäßig local-whatsapp-bridge) # 1. Manuelle Nummer Priorität
# Port 3000 haben wir im Dockerfile definiert if use_manual and target_number:
url = "http://866fd2eb-whatsapp-bridge:3000/send" targets.append(target_number)
try: # 2. Rundruf an alle
response = requests.post(url, json={ elif recipient == "all_accounts":
"number": number, for e in entries:
"message": message targets.append(e.data.get(CONF_PHONE_NUMBER))
}, timeout=10)
if response.status_code != 200: # 3. Spezifischer Account aus Dropdown
_LOGGER.error("Fehler beim Senden: %s", response.text) elif recipient:
except Exception as e: for e in entries:
_LOGGER.error("Verbindung zum Add-on fehlgeschlagen: %s", str(e)) if e.title.lower() == recipient.lower():
targets.append(e.data.get(CONF_PHONE_NUMBER))
hass.services.async_register( # Sende-Vorgang
DOMAIN, SERVICE_SEND_MESSAGE, send_whatsapp_msg, schema=SERVICE_SCHEMA for num in targets:
) url = "http://866fd2eb-whatsapp-bridge:3000/send"
try:
await hass.async_add_executor_job(
lambda: requests.post(url, json={
"number": num,
"message": message
}, timeout=10)
)
_LOGGER.info("WhatsApp message successfully sent to %s", num)
except Exception as e:
_LOGGER.error("Failed to send WhatsApp to %s: %s", num, str(e))
hass.services.async_register(DOMAIN, "send_message", handle_send_message)
return True return True
async def async_unload_entry(hass: HomeAssistant, entry):
"""Unload a config entry."""
return True

View File

@@ -0,0 +1,25 @@
from homeassistant import config_entries
import voluptuous as vol
from .const import DOMAIN, CONF_PHONE_NUMBER, CONF_ACCOUNT_NAME
class WhatsAppBridgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for WhatsApp Bridge."""
VERSION = 1
async def async_step_user(self, user_input=None):
"""First step when adding the integration via UI."""
errors = {}
if user_input is not None:
return self.async_create_entry(
title=user_input[CONF_ACCOUNT_NAME],
data=user_input
)
return self.async_show_form(
step_id="user",
data_schema=vol.Schema({
vol.Required(CONF_ACCOUNT_NAME, default="John Doe"): str,
vol.Required(CONF_PHONE_NUMBER, default="491701234567"): str,
}),
errors=errors,
)

View File

@@ -0,0 +1,3 @@
DOMAIN = "whatsapp_bridge_integration"
CONF_PHONE_NUMBER = "phone_number"
CONF_ACCOUNT_NAME = "account_name"

View File

@@ -4,6 +4,7 @@
"documentation": "https://git.bahmcloud.de/bahmcloud/Whatsapp-Bridge-Integration", "documentation": "https://git.bahmcloud.de/bahmcloud/Whatsapp-Bridge-Integration",
"dependencies": [], "dependencies": [],
"codeowners": ["@bahmcloud"], "codeowners": ["@bahmcloud"],
"version": "0.1.0", "version": "0.1.4",
"iot_class": "local_polling" "iot_class": "local_polling",
"config_flow": true
} }

View File

@@ -0,0 +1,33 @@
send_message:
name: Send Message
description: Sends a WhatsApp message via the Bahmcloud Bridge.
fields:
recipient:
name: Recipient
description: Select a saved profile or choose "Broadcast to all".
required: true
selector:
select:
options:
- label: "Broadcast to all"
value: "all_accounts"
# Dieser Teil sorgt dafür, dass HA die Namen deiner Accounts anzeigt
custom_value: true
message:
name: Message
description: The content of your WhatsApp message.
required: true
selector:
text:
multiline: true
use_manual_number:
name: Use Manual Number
description: Enable this to ignore the recipient and use the number field below.
default: false
selector:
boolean:
number:
name: Manual Number
description: "Direct phone number (e.g., 491701234567)."
selector:
text: