[DOCS] Modify home assistant configuration changes to reflect MQTT syntax that is required since HomeAssistant 2022.12.0 (#1511)

The MQTT YAML configuration change was optional in 2022.6, but the new syntax (updated above) is now mandatory, and now matches the already updated documentation provided at the top of the page.  I also added the force_update flag to help with the expire_after to give better graphing of temperature/humidity readings.
This commit is contained in:
Yogotech's GITHub account authored and GitHub committed 2023-03-08 05:25:12 -06:00
1 parent 8f47a80303
commit 2a8257d4ce
1 file changed
+35 -37
+35 -37
View File
@@ -81,9 +81,9 @@ From @123, @finity, @denniz03, @jrockstad, @anarchking, @dkluivingh
### Door sensor ### Door sensor
```yaml ```yaml
binary_sensor: mqtt:
- platform: mqtt binary_sensor:
name: "test" - name: "test"
state_topic: "home/OpenMQTTGateway/433toMQTT" state_topic: "home/OpenMQTTGateway/433toMQTT"
value_template: >- value_template: >-
{% if value_json.value == '7821834' %} {% if value_json.value == '7821834' %}
@@ -98,9 +98,9 @@ binary_sensor:
``` ```
```yaml ```yaml
binary_sensor: mqtt:
- platform: mqtt binary_sensor:
name: doorbell - name: doorbell
state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT' state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
#value_template: "{{ value_json.raw }}" #value_template: "{{ value_json.raw }}"
value_template: >- value_template: >-
@@ -111,9 +111,8 @@ binary_sensor:
{% endif %} {% endif %}
off_delay: 30 off_delay: 30
device_class: 'sound' device_class: 'sound'
- binary_sensor:
platform: mqtt - name: light_back_sensor
name: light_back_sensor
state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT' state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
#value_template: '{{ value_jason.value }}' #value_template: '{{ value_jason.value }}'
value_template: >- value_template: >-
@@ -123,9 +122,8 @@ binary_sensor:
{{states('binary_sensor.light_back_sensor') | upper}} {{states('binary_sensor.light_back_sensor') | upper}}
{% endif %} {% endif %}
off_delay: 5 off_delay: 5
- binary_sensor:
platform: mqtt - name: rf_outlet_sensor
name: rf_outlet_sensor
state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT' state_topic: 'home/OpenMQTTGateway/SRFBtoMQTT'
value_template: >- value_template: >-
{% if value_json.value == '16766303' %} {% if value_json.value == '16766303' %}
@@ -137,9 +135,9 @@ binary_sensor:
### Motion sensor ### Motion sensor
```yaml ```yaml
binary_sensor: mqtt:
- platform: mqtt binary_sensor:
name: "Bewegung_Schlafzimmer" - name: "Bewegung_Schlafzimmer"
#device_class: motion #device_class: motion
state_topic: "home/OpenMQTTGateway1/HCSR501toMQTT" state_topic: "home/OpenMQTTGateway1/HCSR501toMQTT"
value_template: '{{ value_json["presence"] }}' value_template: '{{ value_json["presence"] }}'
@@ -151,9 +149,9 @@ binary_sensor:
```yaml ```yaml
#switches #switches
switch: mqtt:
- platform: mqtt switch:
name: Plug1 - name: Plug1
state_topic: "home/OpenMQTTGateway/SRFBtoMQTT" state_topic: "home/OpenMQTTGateway/SRFBtoMQTT"
command_topic: "home/OpenMQTTGateway/commands/MQTTtoSRFB" command_topic: "home/OpenMQTTGateway/commands/MQTTtoSRFB"
value_template: "{{ value_json.value }}" value_template: "{{ value_json.value }}"
@@ -168,49 +166,49 @@ switch:
### Mijia Thermometer BLE ### Mijia Thermometer BLE
```yaml ```yaml
Sensor: mqtt:
- platform: mqtt sensor:
- name: "mijia_thermometer_temperature"
state_topic: 'home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA' # MQTT topic, check MQTT messages; replace AA... with id (BLE MAC) of your device state_topic: 'home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA' # MQTT topic, check MQTT messages; replace AA... with id (BLE MAC) of your device
name: "mijia_thermometer_temperature"
unit_of_measurement: '°C' unit_of_measurement: '°C'
value_template: '{{ value_json.tem | is_defined }}' value_template: '{{ value_json.tem | is_defined }}'
expire_after: 21600 # 6 hours expire_after: 21600 # 6 hours
- platform: mqtt force_update: true
- name: "mijia_thermometer_humidity"
state_topic: 'home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA' state_topic: 'home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA'
name: "mijia_thermometer_humidity"
unit_of_measurement: '%' unit_of_measurement: '%'
value_template: '{{ value_json.hum | is_defined }}' value_template: '{{ value_json.hum | is_defined }}'
expire_after: 21600 # 6 hours expire_after: 21600 # 6 hours
- platform: mqtt force_update: true
- name: "mijia_thermometer_battery"
state_topic: 'home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA' state_topic: 'home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA'
name: "mijia_thermometer_battery"
unit_of_measurement: '%' unit_of_measurement: '%'
value_template: '{{ value_json.batt | is_defined }}' value_template: '{{ value_json.batt | is_defined }}'
expire_after: 21600 # 6 hours expire_after: 21600 # 6 hours
``` force_update: true
```
### Xiaomi Mi Scale V2 BLE (XMTZC05HM) ### Xiaomi Mi Scale V2 BLE (XMTZC05HM)
```yaml ```yaml
sensor: mqtt:
- platform: mqtt sensor:
name: "Weight" - name: "Weight"
state_topic: "home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA" # replace your MQTT topic here state_topic: "home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA" # replace your MQTT topic here
value_template: '{{ value_json["weight"] }}' value_template: '{{ value_json["weight"] }}'
unit_of_measurement: "kg" unit_of_measurement: "kg"
icon: mdi:weight-kilogram icon: mdi:weight-kilogram
- platform: mqtt - name: "Impedance"
name: "Impedance"
state_topic: "home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA" # replace your MQTT topic here also state_topic: "home/OpenMQTTGateway/BTtoMQTT/AAAAAAAAAAAA" # replace your MQTT topic here also
value_template: '{{ value_json["impedance"] }}' value_template: '{{ value_json["impedance"] }}'
unit_of_measurement: "Ohm" unit_of_measurement: "Ohm"
icon: mdi:omega icon: mdi:omega
- platform: template template:
sensors: sensor:
body_mass_index: - name: body_mass_index:
friendly_name: 'Body Mass Index' friendly_name: 'Body Mass Index'
value_template: >- value_template: >-
{% set HEIGHT = (1.76)|float %} # replace your height in meters {% set HEIGHT = (1.76)|float %} # replace your height in meters
@@ -237,9 +235,9 @@ sensor:
### Temperature sensor ### Temperature sensor
```yaml ```yaml
sensor: mqtt:
- platform: mqtt sensor:
name: outdoor temp - name: outdoor temp
state_topic: "home/OpenMQTTGateway/433toMQTT" state_topic: "home/OpenMQTTGateway/433toMQTT"
unit_of_measurement: '°C' unit_of_measurement: '°C'
value_template: > value_template: >