Browse Source

changed mqtt ip

main
Domagoj Zecevic 3 weeks ago
parent
commit
e0571eef88
  1. 6
      README.md
  2. 2
      ROADMAP.md
  3. 4
      docker-compose.yml
  4. 2
      main.go
  5. 2
      main_test.go

6
README.md

@ -41,7 +41,7 @@ docker compose logs -f laundry-status
```
Open `http://<your-server>:8080/` on a phone connected to your home Wi-Fi. By
default the service connects to `192.168.1.12:1883` and subscribes to
default the service connects to `192.168.1.11:1883` and subscribes to
`tele/tasmota_washingmashine_C21183/SENSOR`. No broker is included in the Compose
file; it connects to your existing one.
@ -49,7 +49,7 @@ To override settings, export the environment variables below or place them in a
local `.env` file before running Compose. For example:
```bash
MQTT_BROKER=tcp://192.168.1.12:1883 docker compose up --build -d
MQTT_BROKER=tcp://192.168.1.11:1883 docker compose up --build -d
```
Keep credential files local. The Docker build context excludes `.env` files.
@ -60,7 +60,7 @@ page; no volume or database is required. Stop it with `docker compose down`.
| Variable | Default | Description |
|----------|---------|-------------|
| `MQTT_BROKER` | `tcp://192.168.1.12:1883` | Broker URL, including scheme and port |
| `MQTT_BROKER` | `tcp://192.168.1.11:1883` | Broker URL, including scheme and port |
| `MQTT_TOPIC` | `tele/tasmota_washingmashine_C21183/SENSOR` | Tasmota sensor topic |
| `MQTT_USERNAME` | Empty | Optional MQTT username |
| `MQTT_PASSWORD` | Empty | Optional MQTT password |

2
ROADMAP.md

@ -9,7 +9,7 @@ Objective: show the laundry status from the last 3 one-minute power samples of t
### Decided
- Data source: MQTT topic `tele/tasmota_washingmashine_C21183/SENSOR` (Tasmota JSON, field `ENERGY.Power` in watts).
- Broker: `192.168.1.12:1883`, no credentials assumed. Address, port, topic and credentials (optional) are configurable via env vars.
- Broker: `192.168.1.11:1883`, no credentials assumed. Address, port, topic and credentials (optional) are configurable via env vars.
- Tasmota `TelePeriod` is 10 s, so the plug publishes about 6 messages per minute.
- Architecture: small Go backend, packaged in Docker (Dockerfile plus docker-compose example), deployed by the user on their own server.
- Subscribes to the broker over TCP and runs continuously, whether or not any page is open.

4
docker-compose.yml

@ -3,9 +3,9 @@ services:
build: .
restart: unless-stopped
ports:
- "8080:8080"
- "8089:8080"
environment:
MQTT_BROKER: "${MQTT_BROKER:-tcp://192.168.1.12:1883}"
MQTT_BROKER: "${MQTT_BROKER:-tcp://192.168.1.11:1883}"
MQTT_TOPIC: "${MQTT_TOPIC:-tele/tasmota_washingmashine_C21183/SENSOR}"
MQTT_USERNAME: "${MQTT_USERNAME:-}"
MQTT_PASSWORD: "${MQTT_PASSWORD:-}"

2
main.go

@ -38,7 +38,7 @@ func loadConfig() (config, error) {
}
return config{
MQTTConfig: sensor.MQTTConfig{
Broker: env("MQTT_BROKER", "tcp://192.168.1.12:1883"),
Broker: env("MQTT_BROKER", "tcp://192.168.1.11:1883"),
Topic: env("MQTT_TOPIC", "tele/tasmota_washingmashine_C21183/SENSOR"),
Username: os.Getenv("MQTT_USERNAME"),
Password: os.Getenv("MQTT_PASSWORD"),

2
main_test.go

@ -13,7 +13,7 @@ func TestLoadConfigDefaults(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if got.Broker != "tcp://192.168.1.12:1883" || got.Topic != "tele/tasmota_washingmashine_C21183/SENSOR" || got.HTTPAddr != ":8080" || got.SampleInterval != time.Minute || got.Username != "" || got.Password != "" {
if got.Broker != "tcp://192.168.1.11:1883" || got.Topic != "tele/tasmota_washingmashine_C21183/SENSOR" || got.HTTPAddr != ":8080" || got.SampleInterval != time.Minute || got.Username != "" || got.Password != "" {
t.Fatalf("defaults: %+v", got)
}
}

Loading…
Cancel
Save