diff --git a/roles/homeassistant/templates/mqtt.yaml.j2 b/roles/homeassistant/templates/mqtt.yaml.j2 index 8d70762..c0b7ac3 100644 --- a/roles/homeassistant/templates/mqtt.yaml.j2 +++ b/roles/homeassistant/templates/mqtt.yaml.j2 @@ -2,7 +2,7 @@ sensor: {% for shelly in shellies | selectattr("name", "match", "^shellyplug-s-") | list %} - name: Power Usage - state_topic: home/{{ shelly["room"] }}/{{ shelly["device"] }}/relay/0/power + state_topic: home/{{ shelly["room"] }}/{{ shelly["device"] }}/power unique_id: {{ shelly["name"] }} unit_of_measurement: W device: diff --git a/roles/mosquitto/templates/mosquitto.conf.j2 b/roles/mosquitto/templates/mosquitto.conf.j2 index 917467e..4232fba 100644 --- a/roles/mosquitto/templates/mosquitto.conf.j2 +++ b/roles/mosquitto/templates/mosquitto.conf.j2 @@ -12,5 +12,10 @@ bridge_certfile {{ tls_certs }}/{{ inventory_hostname }}.crt bridge_keyfile {{ tls_private }}/{{ inventory_hostname }}.key {% for shelly in shellies %} +{% if shelly['name'] | regex_search("^shellyplug-s-") %} +topic power out 0 shellies/{{ shelly['name'] }}/relay/0/ home/{{ shelly['room'] }}/{{ shelly['device'] }}/ +topic temperature out 0 shellies/{{ shelly['name'] }}/ home/{{ shelly['room'] }}/{{ shelly['device'] }}/ +{% else %} topic # out 0 shellies/{{ shelly['name'] }}/ home/{{ shelly['room'] }}/{{ shelly['device'] }}/ +{% endif %} {% endfor %} diff --git a/roles/telegraf/templates/telegraf.conf.j2 b/roles/telegraf/templates/telegraf.conf.j2 index 2f1056e..07b71ba 100644 --- a/roles/telegraf/templates/telegraf.conf.j2 +++ b/roles/telegraf/templates/telegraf.conf.j2 @@ -10,7 +10,7 @@ tls_cert = "{{ tls_certs }}/{{ inventory_hostname }}.crt" tls_key = "{{ tls_private }}/{{ inventory_hostname }}.key" topics = [ - "+/+/+/relay/0/power", + "+/+/+/power", "+/+/+/temperature", "+/+/+/sensor/battery", "+/+/+/sensor/lux", @@ -21,9 +21,9 @@ data_format = "value" [[inputs.mqtt_consumer.topic_parsing]] - topic = "+/+/+/relay/0/power" - tags = "location/room/device/_/_/_" - measurement = "_/_/_/_/_/measurement" + topic = "+/+/+/power" + tags = "location/room/device/_" + measurement = "_/_/_/power" [[inputs.mqtt_consumer.topic_parsing]] topic = "+/+/+/temperature"