Refactor mqtt topics for shelly plugs
This commit is contained in:
parent
95c66d976f
commit
d6cc79dcb3
3 changed files with 10 additions and 5 deletions
|
@ -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:
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue