Help with mqtt templating (from Domoticz)

Hi,

There are two solutions that I could figure out:

1.In Domoticz: place the sensor in a floorplan, set mqtt topic to “/” (basically have a separate topic for the sensor; haven’t checked if multiple floorplans could be set, so each sensor has its own). Then in HA the sensor would be:

- platform: mqtt
  state_topic: 'domoticz/out/name/floorplan'
  name: 'ws1_temperature'
  unit_of_measurement: '°C'
  value_template: '{{ value_json.svalue1 }}'
- platform: mqtt
  state_topic: 'domoticz/out/name/floorplan'
  name: 'ws1_humidity'
  unit_of_measurement: '%'
  value_template: '{{ value_json.svalue2 }}'
  1. Use flat (“out”) or flat + hierarchical ( “out + /” if needed to combine with first option above) topic for mqtt in Domoticz and set an automation that would read each sensor (no need for floorplan).
    #automation - based on the payload in the first message. If weather station has only temperature readings lose the second sensor.

    - alias: WS1
       initial_state: True
       trigger:
         - platform: mqtt
           topic: 'domoticz/out'
       condition: 
         condition: template
         value_template: '{{ "82019" in trigger.payload }}'  
       action:
         - service: mqtt.publish
           data_template:
             topic: "home/weatherstation1/temp"
             payload_template: '{{ trigger.payload_json.svalue1 }}'
         - service: mqtt.publish
           data_template:
             topic: "home/weatherstation1/hum"
             payload_template: '{{ trigger.payload_json.svalue2 }}'
    

#Sensors

- platform: mqtt  
  state_topic: 'home/weatherstation1/temp'  
  name: 'ws1_temperature'  
  unit_of_measurement: '°C'
- platform: mqtt  
  state_topic: 'home/weatherstation1/hum'  
  name: 'ws1_humidity'  
  unit_of_measurement: '%'