I am slowly approaching my goal, but unfortunately I have not yet reached it. I have searched various forums and websites, but there is no way that I have really found 100%. Most solutions use Tasoma for reading/transmitting, but I can’t use imho.
About my problem:
I have set up a small weather station based on a RPI Zero W with Pimoroni Enviro (sensors: BME280, LTR-559 & noise sensor) and send the data via MQTT to my broker. There .json data arrives. The connection also works. I have tested this with a MQTT.fx client.
Since I am still quite new in the whole automation topic, I can’t find out how to get displayable values for my OH2 from the .json values. It seems that I need the JSONPATH Transformation Binding, which I have also installed via the PaperUI.
Can someone please explain to me step by step what is necessary? I am just at the end of my Latin. I thank you very much.
Hej folks, please excuse me for not creating a forum conform request. I have already read several documentations and just did not know what to do. I definitely do not expect complete soultions, because I want to learn something.
To your questions:
That is what I tried to describe above. I tried to transform my generated .json data to display it in OH. Unfortunately the command did not work or something is missing.
Although, as written above, I have already read various documentations, I did not know until now that I had to create a Thing configuration. So far I have only created a MQTT Generic Thing and tried to link my values via a channel.
Then it looks like you only need to use the following for your JSONPATH transformation:
JSONPATH:$.pressure
For Incoming Value Transformation
Although I’m slightly confused about the three JSON messages you show - are they at different times? Different sensors?
Note also that your Items are using v1 MQTT binding configuration, but it looks like you’re using the V2 MQTT binding. See here for how to set that up:
No, if I let the script continue, it will normalise. Only the first value always falls out of line. Could it be due to the delay?
Just look at the humidity. 100% is the maximum there and the script spits out 134%.
i have now tried to configure my things and items using your example. Unfortunately it doesn’t create a thing using the .things configuration.
My thing configuration:
Bridge mqtt:systemBroker:openHAB [ host="192.168.0.1", port="1883", secure=false, username="openhabian", password="mypasswd"]
{
Thing topic thermometer "Thermometer" {
Channels:
Type number : temperature "Temperatur" [ stateTopic="enviroplus/kinderzimmer/thermometer", transformationPattern="JSONPATH:$.temperature"]
Type number : pressure "Luftdruck" [ stateTopic="enviroplus/kinderzimmer/thermometer", transformationPattern="JSONPATH:$.pressure"]
Type number : humidity "Luftfeuchtigkeit [ stateTopic="enviroplus/kinderzimmer/thermometer", transformationPattern="JSONPATH:$.humidity"]
Type number : lux "Beleuchtungsstärke" [ stateTopic="enviroplus/kinderzimmer/thermometer", transformationPattern="JSONPATH:$.lux"]
}
}
My item configuration
Number temperature "Temperatur" { channel="mqtt:topic:openHAB:mything:temperature" }
Number pressure "Luftdruck " { channel="mqtt:topic:openHAB:mything:pressure" }
Number humidity "Luftfeuchtigkeit" { channel="mqtt:topic:openHAB:mything:humidity" }
Number lux "Beleuchtungsstärke" { channel="mqtt:topic:openHAB:mything:lux" }
How do I still get the units (°C, %, hPa, lx) in my view?
I see no new Thing in my PaperUI. I thought a new Thing is created with the file?
Unfortunately this does not say anything. I save the Thing in the directory /srv/openhab2-conf/things with the title thermometer.things
I’ve created the file with sudo nano thermometer.things
Is there another command with which I can test the file?
I installed openHAB with a pre-configured SD-card image on a Raspberry Pi and then updated via openhabian-config.
I can just see that my configurations are also stored in the folder /etc/openhab2/things as well. However, the documentation also says that my other folder is not wrong.
Anyway, the thing is unfortunately not created and I don’t know the reason.
I am a bit confused, because until now all manually created items or things were created. Also the Items shown above are created normally. Only this one Thing is not created.
OK, you’ve just experienced the annoying bug with Things files!
What I do, instead of restarting openHAB, is deliberately corrupt the Things file (remove a {, for example), then save. openHAB will complain and unload the Things. Then, restore the Things file (put the { back in) and re-save: you should see the logs load up the Things again!