[SOLVED] Mqtt problem generic mqtt think

hello
i have a problem with the Generic MQTT Think.
My setup BME280 sensor connected with an ESP32 works fine.

the openhabian log viewer show the mqtt like this

mqtt:broker:81011726:Wetter triggered {“location”:“home/weather”,“temperature”:23.45,“pressure”:1025.70,“humidity”:47.87}

how config the generic mqtt think ?

I read the Dokumentation but i have no plan …

Sorry for this bad english it is 40 year ago i have learn it in school …

Are you wanting to use PaperUI or files?

for the better understanding i use the PaperUi

my try with mqtt.tings make my not happy.

String STemperatureESP1 "Outside temperature (ESP1) [%s °C]" {mqtt="<[mosquitto:b2a88b04/wetter/temperature:state:default]"}
String SHumidityESP1 "Outside humidity (ESP1) [%s%%]" {mqtt="<[mosquitto:b2a88b04/wetter/humidity:state:default]"}
String SPressureESP1 "Pressure (ESP1) [%s hPa]" {mqtt="<[mosquitto:b2a88b04/wetter/pressure:state:default]"}


Number TemperatureESP1 "Outside temperature [%.1f °C]" <temperature> (Temperatures)
Number HumidityESP1 "Outside humidity [%.1f%%]" <humidity> (Humidities)
Number PressureESP1 "Outside pressure [%.1f hPa]" <pressure> (Pressures)

my mistake the i think is the first part … mqtt = <[mosquitto:b2a88b04…

openhab s log viewer show this

[WARN ] [nal.handler.AbstractMQTTThingHandler] - Channel temp not supported

You are using the MQTT1 Syntax for your items or did you really understand the posted lines as the Thing definition?
Please read this

i am new in openhab und i don’t now the different syntax the posted line are my try understanding the function …

tHow can I view the data from my ESP32 MQTT client as individual values in the PaperUI?
I have attached the image of my broker in the PaperUI.
The lines of code from the previous post were an attempt by me to understand configuration.
I have already read the instructions for the MQTT. But without help, I can not get any further.
how do I have to configure the “Generic mqtt think” to the individual
in the PaparUI

I hope the google translated now understandable:grinning:

The screenshot shows the Broker-Thing (i.e. the Brigde or Connection from openHAB to your MQTT Broker), this one should be ONLINE.
Now you need to create a Generic MQTT Thing (Under Configuration Things click on the plus-sign, select “MQTT Thing Binding” and “Add Manually”).
Within the created Generic MQTT Thing, select your MQTT Broker Thing as the Bridge and create your needed channels as written in the above linked documentation.

After some attempts, I now have the following ad in the PaperUI

this presentation is very confusing. How should the
payload msg look so I use the different readings
can represent individually
at the moment it looks like this

“{” Location “:” home / weather “,” temperature “: 23.6,” pressure “: 1030.73,” humidity “: 46.67}”

if I now have the client message with the
“Incoming value transformation” selection wants to evaluate as follows
“JSONPATH: device.status.temperature $.”

does the message sent by the client have to have an appropriate format?

My boot.py file looks like this

from umqtt.robust import MQTTClient
import bme280
import network
import machine
from time import sleep

if machine.reset_cause() == machine.DEEPSLEEP_RESET:
    print('woke from a deep sleep')
# define environment variables
LOCATION         = "home/weather"
MQTT_BROKER      = "192.168.2.103"
MQTT_TOPIC       = "sensors/"+LOCATION
WLAN_SSID        = "WLAN"
WLAN_PASS        = "xxxxxxxxxxx"

c = MQTTClient("espressiv"+LOCATION,MQTT_BROKER)

# WLAN connection
def do_connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        wlan.connect(WLAN_SSID,WLAN_PASS)
        while not wlan.isconnected():
            pass

def do_disconnect():
    wlan = network.WLAN(network.STA_IF)
    wlan.disconnect()
    wlan.active(False)

# publish topic to mqtt-broker
def write_mqtt(topic,temperature,pressure,humidity):
    payload = b'{"location":"' + LOCATION + '","temperature":' + temperature + ',"pressure":' + pressure + ',"humidity":' + humidity + '}'
    try:
        c.connect()
        c.publish(b""+topic,payload)
        c.disconnect()
    except Exception as e:
        print(str(e))

# initialize BME280
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
bme = bme280.BME280(i2c=i2c)

# establish connection
do_connect()

# initialize RTC
#p = machine.Pin(12,machine.Pin.OUT)
#rtc = machine.RTC()
#rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

# read temperature, pressure, humidity
t,p,h = bme.values
write_mqtt(MQTT_TOPIC,t[:-1],p[:-3],h[:-1]) # cut the last character, else it's no number!

#import machine as m
#r = m.RTC()
#r.irq(trigger=r.ALARM0, wake=m.DEEPSLEEP)
#r.alarm(r.ALARM0, 300000)

# set RTC.ALARM0 to fire after 5 minutes (waking the device)
#rtc.alarm(rtc.ALARM0, 300000)
do_disconnect()
# put the device to sleep for 10 seconds
machine.deepsleep(60000)
m.deepsleep()

I hope to recognize that what my questions are about. Perhaps in the forum someone who is familiar with “mircoPython” and knows how to format paylod so that the readings individually as chanel
can be read out.

With the correct transformation you should be able to asign the temperature value to that channel.
How did you setup this channel in the first place? I’d say you did not use transformation.

My temperature channel looks like:

The messages received look like:
{"Time":"2019-03-29T19:23:49","AM2301":{"Temperature":17.5,"Humidity":58.4},"TempUnit":"C"}

…and don’t forget to install the needed transformation service!

I tried my message from the client

{“Location”, “pressure” 23:33: “home / weather”, “temperature” 1030.82, “humidity”: 47.93}

with JSONPATH: $ .location.temperature to configurate
but it does not work

If I have the same message now
on the following website
https://jsonpath.herokuapp.com

then I get json path option
$ … temperature

following issue
[
23:33
]
what else is in openhab2 that i do not get this issue?

rule "Convert JSON to Item Type Number"
  when
    Item Temperature_json changed
 then
    // use the transformation service to retrieve the value
    val newValue = transform("JSONPATH", "$..temperature", Temperature_json.state.toString)

    // post the new value to the Number Item
    Temperature.postUpdate( newValue )
 end

[WARN ] [l.generic.ChannelStateTransformation] - Transformation service JSONPATH for pattern $.temperature not found!

As I told you before, install the transformation service JSONPATH via PaperUI!

Thank you for your help the last post was important.
It is not so easy in the forum everything in English … translate first
… then try it out and sometimes read something over

with me it’s easy then

JSONPATH: $ … temperature
is working .

I thank you for your patience!