Skip to content

Commit

Permalink
Add MQTT Command Topics
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Jan 24, 2025
1 parent 68e8b1a commit 3d739c3
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 11 deletions.
6 changes: 3 additions & 3 deletions docs/de/guide/firmware/additions.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ i2c: // [!code ++] // [!code focus]
## Fortgeschrittene Beispiele
### Home Assistant

::: details Sending Bus commands
::: details Bus Commands senden
Mit Home Assistant kannst du Aktionen nutzen, um Commands über den Bus zu senden.
Benutze entweder `command` für reine 32 Bit Befehle oder `type`, `address`, `payload` und `serial_number` um Befehle über den Command Builder zu senden.
Benutze entweder `command` für hexadezimale Befehle oder `type`, `address`, `payload` und `serial_number` um Befehle über den Command Builder zu senden.

> [!INFO]
> Denk an das führende `0x` beim Senden eines Befehls mit der `command` Eigenschaft. Wenn du es weglässt, musst du den HEX-Befehl zuerst in eine Dezimalzahl umwandeln.
Expand All @@ -92,7 +92,7 @@ data:
serial_number: 0
```

32-Bit Befehle via `command`:
Hexadezimale Befehle via `command`:
```yaml
service: esphome.doorman_s3_send_tc_command_raw
data:
Expand Down
45 changes: 45 additions & 0 deletions docs/de/guide/firmware/mqtt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## MQTT Firmware

Bei Verwendung der MQTT-Firmware werden verschiedene Topics an deinen Broker gesendet. So funktioniert die Struktur der Topics und Steuerung.

### Topic Struktur
Jede Entität veröffentlicht ihren Status auf einem Topic im folgenden Format:
```
<TOPIC_PREFIX>/<COMPONENT_TYPE>/<COMPONENT_NAME>/state
```

Du kannst bestimmte Entitäten steuern, indem du einen Befehl an ein Topic mit folgendem Format sendest:
```
Topic: <TOPIC_PREFIX>/<COMPONENT_TYPE>/<COMPONENT_NAME>/command
Payload: ON oder OFF oder was immer unterstützt wird
```

### Beispiel
Um die [Ring-To-Open](../automation/ring-to-open.md) Automatisierung zu aktivieren oder zu deaktivieren, sende ON oder OFF als Payload an dieses Topic:
```
Topic: doorman-s3/switch/ring_to_open/command
Payload: ON
```

### Spezielle Topics
Es gibt spezielle Topics, die erweiterte Befehle ermöglichen.

#### Senden eines hexadezimalen Commands
Um einen hexadezimalen Befehl an den Bus zu senden, verwende das Topic `doorman-s3/send_raw_command` mit einer JSON-Payload. Beispiel:
```json
{
"command": 0x1C30BA80,
"is_long": false
}
```

#### Senden eines Commands mit Command Builder
Um einen Befehl mittels Command Builder an den Bus zu senden, verwende das Topic `doorman-s3/send_command` mit einer JSON-Payload. Beispiel:
```json
{
"type": "open_door",
"address": 0,
"payload": 0,
"serial_number": 123456
}
```
4 changes: 3 additions & 1 deletion docs/de/guide/firmware/nuki-bridge-firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ Du kannst dein Gerät entweder über den `Nuki Unpair Device`-Button in Home Ass
Falls dein Schloss bereits mit Doorman gekoppelt ist, drücke die `FLASH`- oder `PRG`-Taste auf der Doorman-Platine für 5 Sekunden, bis die RGB-Status-LED lila zu blinken beginnt. Dein Nuki Lock wird dann entkoppelt. Beachte, dass der Pairing-Modus nach 30 Sekunden abläuft.
:::

<!--@include: ./additions.md-->
<!--@include: ./additions.md-->

<!--@include: ./mqtt.md-->
4 changes: 3 additions & 1 deletion docs/de/guide/firmware/stock-firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ Dies ist die minimale ESPHome-Konfigurations-YAML-Datei für die Verwendung mit
```
:::
<!--@include: ./additions.md-->
<!--@include: ./additions.md-->
<!--@include: ./mqtt.md-->
2 changes: 1 addition & 1 deletion docs/en/guide/firmware/additions.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ data:
serial_number: 123456
```

32-Bit Commands via `command`:
Hexadecimal Commands via `command`:
```yaml
service: esphome.doorman_s3_send_tc_command_raw
data:
Expand Down
45 changes: 45 additions & 0 deletions docs/en/guide/firmware/mqtt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## MQTT Firmware

When using the MQTT firmware, various topics are published to your broker. Here's how the topic structure and controls work.

### Topic Structure
Each entity publishes its state to a topic in the following format:
```
<TOPIC_PREFIX>/<COMPONENT_TYPE>/<COMPONENT_NAME>/state
```

You can control certain entities by publishing a command to this topic format:
```
Topic: <TOPIC_PREFIX>/<COMPONENT_TYPE>/<COMPONENT_NAME>/command
Payload: ON or OFF or whatever is supported
```

### Example
To enable or disable the [Ring-To-Open](../automation/ring-to-open.md) automation, send `ON` or `OFF` as the payload to the topic:
```
Topic: doorman-s3/switch/ring_to_open/command
Payload: ON
```

### Special Topics
Certain special topics allow for advanced commands.

#### Send a hexadecimal Command
To send a hexadecimal command to the bus, use the topic `doorman-s3/send_raw_command ` with a JSON payload. Here's an example payload:
```json
{
"command": 0x1C30BA80,
"is_long": false
}
```

#### Send a parsed Command
To send a command via command builder to the bus, use the topic `doorman-s3/send_command` with a JSON payload. Here's an example payload:
```json
{
"type": "open_door",
"address": 0,
"payload": 0,
"serial_number": 123456
}
```
4 changes: 3 additions & 1 deletion docs/en/guide/firmware/nuki-bridge-firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ You can unpair your device using either the `Nuki Unpair Device` button in Home
If your lock is already paired with Doorman, press the `FLASH` or `PRG` button on the Doorman PCB for 5 seconds until the RGB status LED starts flashing purple. Your Nuki Lock will then be unpaired. Note that the pairing mode will time out after 30 seconds.
:::

<!--@include: ./additions.md-->
<!--@include: ./additions.md-->

<!--@include: ./mqtt.md-->
4 changes: 3 additions & 1 deletion docs/en/guide/firmware/stock-firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ This is the minimal ESPHome configuration YAML file for use with MQTT. Be sure t
```
:::
<!--@include: ./additions.md-->
<!--@include: ./additions.md-->
<!--@include: ./mqtt.md-->
4 changes: 4 additions & 0 deletions firmware/addons/debug-utilities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ binary_sensor:
id: debug_bus_connected
name: Bus Connection Status
icon: "mdi:connection"
disabled_by_default: true
lambda: |-
if (id(bus_voltage).state >= 3) {
return true;
} else {
return false;
}
web_server:
sorting_group_id: sorting_group_system

text:
- platform: template
Expand Down Expand Up @@ -57,6 +60,7 @@ button:
id: debug_restart_control_unit
name: "System Restart"
icon: mdi:restart
disabled_by_default: true
on_press:
- tc_bus.send:
command: 0x5100
Expand Down
40 changes: 37 additions & 3 deletions firmware/addons/mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,41 @@ esphome:
- script.execute: update_led

mqtt:
on_message:
- topic: doorman/test
on_json_message:
- topic: doorman-s3/send_tc_command_raw
then:
- tc_bus.send:
command: !lambda |-
int command = 0;
if (x.containsKey("command"))
command = x["command"];
return command;
is_long: !lambda |-
bool is_long = false;
if (x.containsKey("is_long"))
is_long = x["is_long"];
return is_long;
- topic: doorman-s3/send_tc_command
then:
- # ...
- tc_bus.send:
type: !lambda |-
CommandType commandType = COMMAND_TYPE_UNKNOWN;
if (x.containsKey("type"))
commandType = string_to_command_type(x["type"]);
return commandType;
address: !lambda |-
int address = 0;
if (x.containsKey("address"))
address = x["address"];
return address;
payload: !lambda |-
int payload = 0;
if (x.containsKey("payload"))
payload = x["payload"];
return payload;
serial_number: !lambda |-
int serial_number = 0;
if (x.containsKey("serial_number"))
serial_number = x["serial_number"];
return serial_number;

0 comments on commit 3d739c3

Please sign in to comment.