diff --git a/host_vars/warpsrvint b/host_vars/warpsrvint index 661972bca8d9d854b885ec12489899f08bf1dfe8..1294e6c12e30082dffa759ec656f9452bc4afb21 100644 --- a/host_vars/warpsrvint +++ b/host_vars/warpsrvint @@ -114,3 +114,10 @@ borgbackup_user: sshkeys: - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIENYus4S4XOaGHVL4B6vbnIrovtqaCT1lbEF73StiTt+ root@webserver" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGIBBvcQaD0MmEHY0q+lcoMN9sXHs/HnSiXGsAhm+Vwp root@vorstand" + +mqtt_sensors_temp: + - { id: "hauptraum", name: "Hauptraum", groups: "gHauptraum" } + - { id: "vortragsraum", name: "Vortragsraum", groups: "gVortragsraum" } + +mqtt_sensors_feinstaub: + - { id: "feinstaub01", name: "Feinstaub01", groups: "gHauptraum" } diff --git a/warpsrvint/docker_openhab/tasks/main.yml b/warpsrvint/docker_openhab/tasks/main.yml index 30304e0f2983f0aac07384ff3da194318c5188fb..9e96c94160f72b579312ee2a3351f9237c36318b 100644 --- a/warpsrvint/docker_openhab/tasks/main.yml +++ b/warpsrvint/docker_openhab/tasks/main.yml @@ -52,6 +52,7 @@ dest: "/srv/openhab/{{ item }}" with_items: - conf/items/groups.items + - conf/items/mqtt.items - conf/items/network.items - conf/items/other.items - conf/items/weather.items @@ -59,9 +60,11 @@ - conf/persistence/rrd4j.persist - conf/services/addons.cfg - conf/services/influxdb.cfg + - conf/services/mqtt.cfg - conf/services/network.cfg - conf/services/runtime.cfg - conf/things/astro.things + - conf/things/mqtt.things - conf/things/network.things - conf/things/weather.things diff --git a/warpsrvint/docker_openhab/templates/conf/items/groups.items b/warpsrvint/docker_openhab/templates/conf/items/groups.items index ac6d66b1b62b14f5fff1e73130955aa9fd5b6732..3315642043821b94d120f066ee58d0ee5c2924f3 100644 --- a/warpsrvint/docker_openhab/templates/conf/items/groups.items +++ b/warpsrvint/docker_openhab/templates/conf/items/groups.items @@ -4,8 +4,8 @@ // Liste der Icons: https://www.openhab.org/docs/configuration/iconsets/classic/ // Liste der Semantic Tags: https://github.com/openhab/openhab-core/blob/main/bundles/org.openhab.core.semantics/model/SemanticTags.csv -Group gEWerkstatt "EWerkstatt" <settings> ["GuestRoom"] Group gFlur "Flur" <corridor> ["Corridor"] +Group gHauptraum "Hauptraum" <settings> ["GuestRoom"] Group gHolzwerkstatt "Holzwerkstatt" <settings> ["GuestRoom"] Group gKueche "Küche" <kitchen> ["Kitchen"] Group gLounge "Lounge" <sofa> ["LivingRoom"] diff --git a/warpsrvint/docker_openhab/templates/conf/items/mqtt.items b/warpsrvint/docker_openhab/templates/conf/items/mqtt.items new file mode 100644 index 0000000000000000000000000000000000000000..0c9c3786ee69fe766c63694fc4c7718e814be657 --- /dev/null +++ b/warpsrvint/docker_openhab/templates/conf/items/mqtt.items @@ -0,0 +1,25 @@ + +{% for device in mqtt_sensors_temp %} + +Number MQTT_{{ device.id }}_temp "Sensor {{ device.name }} Temp [%.1f °C]" <temperature> ({{ device.groups }}) ["Measurement","Temperature","CurrentTemperature"] { + channel="mqtt:topic:mosquitto:{{ device.id }}:temp" +} + +Number MQTT_{{ device.id }}_pressure "Sensor {{ device.name }} Pressure [%.1f hPa]" <pressure> ({{ device.groups }}) ["Measurement","Pressure"] { + channel="mqtt:topic:mosquitto:{{ device.id }}:pressure" +} + +Number MQTT_{{ device.id }}_humidity "Sensor {{ device.name }} Humidity [%.1f %%]" <humidity> ({{ device.groups }}) ["Measurement","Humidity","CurrentHumidity"] { + channel="mqtt:topic:mosquitto:{{ device.id }}:humidity" +} + +{% endfor %} + +{% for device in mqtt_sensors_feinstaub %} + +Number MQTT_{{ device.id }}_feinstaub_2_5 "Sensor {{ device.name }} 2.5 PM [%.1f µg/m³]" ({{ device.groups }}) ["Measurement"] { + channel="mqtt:topic:mosquitto:{{ device.id }}:feinstaub_2_5" +} + +{% endfor %} + diff --git a/warpsrvint/docker_openhab/templates/conf/services/mqtt.cfg b/warpsrvint/docker_openhab/templates/conf/services/mqtt.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/warpsrvint/docker_openhab/templates/conf/things/mqtt.things b/warpsrvint/docker_openhab/templates/conf/things/mqtt.things new file mode 100644 index 0000000000000000000000000000000000000000..8c49e918aff72258e4fafa6a1fd606600a94aeb1 --- /dev/null +++ b/warpsrvint/docker_openhab/templates/conf/things/mqtt.things @@ -0,0 +1,28 @@ + +Bridge mqtt:broker:mosquitto [ host="{{ int_ip4 }}", secure=false, enableDiscovery=false ] +{ + +{% for device in mqtt_sensors_temp %} + + Thing topic {{ device.id }} { + Channels: + Type number : temp "Sensor {{ device.name }} Temp" [ stateTopic="ESPHome/esphome_{{ device.id }}/sensor/temp/state" ] + Type number : pressure "Sensor {{ device.name }} Pressure" [ stateTopic="ESPHome/esphome_{{ device.id }}/sensor/pressure/state" ] + Type number : humidity "Sensor {{ device.name }} Humidity" [ stateTopic="ESPHome/esphome_{{ device.id }}/sensor/humidity/state" ] + } + + +{% endfor %} + +{% for device in mqtt_sensors_feinstaub %} + + Thing topic {{ device.id }} { + Channels: + Type number : feinstaub_2_5 "Sensor {{ device.name }} 2.5 PM" [ stateTopic="ESPHome/esphome_{{ device.id }}/sensor/feinstaub_2_5/state" ] + } + + +{% endfor %} + +} +