Skip to content

Commit

Permalink
Merge pull request #177 from calvinmclean/feature/record-commands
Browse files Browse the repository at this point in the history
Telegraf adapter for commands and improve MQTT configuration
  • Loading branch information
calvinmclean authored Aug 31, 2024
2 parents 9e6af0e + 6e8abf6 commit 9fafe91
Show file tree
Hide file tree
Showing 31 changed files with 175 additions and 732 deletions.
194 changes: 0 additions & 194 deletions deploy/Acornfile

This file was deleted.

4 changes: 0 additions & 4 deletions deploy/base/configs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ mqtt:
broker: "mosquitto"
port: 1883
client_id: "garden-app"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
influxdb:
address: "http://influxdb:8086"
token: "my-secret-token"
Expand Down
24 changes: 19 additions & 5 deletions deploy/base/configs/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,24 @@
[[inputs.mqtt_consumer]]
servers = ["tcp://mosquitto:1883"]
topics = [
"${MQTT_WATER_TOPIC}",
"${MQTT_LIGHT_TOPIC}",
"${MQTT_MOISTURE_TOPIC}",
"${MQTT_LOGGING_TOPIC}",
"${MQTT_HEALTH_TOPIC}"
"+/data/water",
"+/data/light",
"+/data/moisture",
"+/data/temperature",
"+/data/humidity",
"+/data/logs",
"+/data/health"
]
data_format = "influx"
[[inputs.mqtt_consumer]]
servers = ["tcp://mosquitto:1883"]
topics = [
"+/command/+"
]
data_format = "json"
tag_keys = ["id", "position"]
json_string_fields = ["state", "for_duration"]
name_suffix = "_command"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "+/command/+"
measurement = "_/_/measurement"
5 changes: 0 additions & 5 deletions deploy/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ configMapGenerator:
- INFLUXDB_TOKEN=my-secret-token
- INFLUXDB_ORG=garden
- INFLUXDB_BUCKET=garden
- MQTT_WATER_TOPIC="+/data/water"
- MQTT_LIGHT_TOPIC="+/data/light"
- MQTT_MOISTURE_TOPIC="+/data/moisture"
- MQTT_LOGGING_TOPIC="+/data/logs"
- MQTT_HEALTH_TOPIC="+/data/health"
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
resources:
- garden_app.yaml
Expand Down
25 changes: 0 additions & 25 deletions deploy/base/telegraf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,6 @@ spec:
- name: config
mountPath: /etc/telegraf
env:
- name: MQTT_WATER_TOPIC
valueFrom:
configMapKeyRef:
name: shared-environment
key: MQTT_WATER_TOPIC
- name: MQTT_LIGHT_TOPIC
valueFrom:
configMapKeyRef:
name: shared-environment
key: MQTT_LIGHT_TOPIC
- name: MQTT_MOISTURE_TOPIC
valueFrom:
configMapKeyRef:
name: shared-environment
key: MQTT_MOISTURE_TOPIC
- name: MQTT_LOGGING_TOPIC
valueFrom:
configMapKeyRef:
name: shared-environment
key: MQTT_LOGGING_TOPIC
- name: MQTT_HEALTH_TOPIC
valueFrom:
configMapKeyRef:
name: shared-environment
key: MQTT_HEALTH_TOPIC
- name: INFLUXDB_TOKEN
valueFrom:
configMapKeyRef:
Expand Down
4 changes: 0 additions & 4 deletions deploy/configs/garden-app/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ mqtt:
broker: "mqtt"
port: 1883
client_id: "garden-app-acorn"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
influxdb:
address: "http://influxdb:8086"
token: "my-secret-token"
Expand Down
26 changes: 19 additions & 7 deletions deploy/configs/telegraf/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,24 @@
[[inputs.mqtt_consumer]]
servers = ["tcp://mqtt:1883"]
topics = [
"${MQTT_WATER_TOPIC}",
"${MQTT_LIGHT_TOPIC}",
"${MQTT_MOISTURE_TOPIC}",
"${MQTT_TEMPERATURE_TOPIC}",
"${MQTT_HUMIDITY_TOPIC}",
"${MQTT_LOGGING_TOPIC}",
"${MQTT_HEALTH_TOPIC}"
"+/data/water",
"+/data/light",
"+/data/moisture",
"+/data/temperature",
"+/data/humidity",
"+/data/logs",
"+/data/health"
]
data_format = "influx"
[[inputs.mqtt_consumer]]
servers = ["tcp://mqtt:1883"]
topics = [
"+/command/+"
]
data_format = "json"
tag_keys = ["id", "position"]
json_string_fields = ["state", "for_duration"]
name_suffix = "_command"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "+/command/+"
measurement = "_/_/measurement"
8 changes: 0 additions & 8 deletions deploy/env_file
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ INFLUXDB_TOKEN="my-secret-token"
INFLUXDB_ORG="garden"
INFLUXDB_BUCKET="garden"

# Telegraf
MQTT_WATER_TOPIC="+/data/water"
MQTT_LIGHT_TOPIC="+/data/light"
MQTT_MOISTURE_TOPIC="+/data/moisture"
MQTT_TEMPERATURE_TOPIC="+/data/temperature"
MQTT_HUMIDITY_TOPIC="+/data/humidity"
MQTT_LOGGING_TOPIC="+/data/logs"
MQTT_HEALTH_TOPIC="+/data/health"
# Grafana
GF_SECURITY_ADMIN_USER="${ADMIN_USER}"
GF_SECURITY_ADMIN_PASSWORD="${ADMIN_PSWD}"
Expand Down
4 changes: 0 additions & 4 deletions deploy/overlays/dev/configs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ mqtt:
broker: "mosquitto"
port: 1883
client_id: "garden-controller"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
controller:
topic_prefix: "garden"
num_zones: 3
Expand Down
4 changes: 0 additions & 4 deletions docs/app_advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ mqtt:
broker: "localhost"
port: 1883
client_id: "garden-app"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
influxdb:
address: "http://localhost:8086"
token: "my-token"
Expand Down
4 changes: 0 additions & 4 deletions docs/hydroponics_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ mqtt:
broker: "mosquitto"
port: 1883
client_id: "garden-app"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
influxdb:
address: "http://influxdb:8086"
token: "my-secret-token"
Expand Down
4 changes: 0 additions & 4 deletions docs/indoor_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ mqtt:
broker: "mosquitto"
port: 1883
client_id: "garden-app"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
influxdb:
address: "http://influxdb:8086"
token: "my-secret-token"
Expand Down
4 changes: 0 additions & 4 deletions garden-app/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ mqtt:
broker: "localhost"
port: 1883
client_id: "garden-app"
water_topic: "{{.Garden}}/command/water"
stop_topic: "{{.Garden}}/command/stop"
stop_all_topic: "{{.Garden}}/command/stop_all"
light_topic: "{{.Garden}}/command/light"
influxdb:
address: "http://localhost:8086"
token: "my-token"
Expand Down
Loading

0 comments on commit 9fafe91

Please sign in to comment.