[SOLVED] Esp8266-01 DHT22 data isn't showing in sitemap

Hello everyone! Openhab newbie here. Could someone please help me out?

I’ve been messing around with Tasmota running on Sonoff’s. Everything has been going good until now. I’m able to switch the Sonoff relay using mqtt. So, I flashed an esp8266-01 with tasmota and hooked a dht22 to the gpio2 pin. Sensor data is showing in the web guy.

Snip20180418_3

I’m trying to publish the data to my openhab2 machine (RaspPi3 with Openhabian) using mqtt. Here is my item and sitemap code…

Number Main_Temp "Main Temp" <temperature> { mqtt="<[OH2:tele/Living_Temp/SENSOR]" }
Text item=Main_Temp  label="Living Temp [%.1f °F]"

Could someone kindly inform me on what I’m doing wrong?

Forgot to add,

Using MQTTfx when I subscribe to my sensor topic I get this every five minutes…

{"Time":"1970-01-01T01:10:23","AM2301":{"Temperature":75.4,"Humidity":54.2},"TempUnit":"F"}

After some reading I discovered that the sensor data is in json form. Looking at the events.log… it says something about a configuration error. This is what I have done:

-Item-

String Main_Temp_json "Main Temp [JSONPATH($.AM2301.Temperature):%s °F]" { mqtt="<[OH2:tele/Living_Temp/SENSOR]"}
Number Main_Temp  "Main Temp [%.1f °F]"

-Sitemap-

 Text item=Main_Temp  label="Living Temp [%.1f °F]"

-Rule-

// Test rule for changing JSON String to Number

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

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

-events.log-

2018-04-19 00:33:51.055 [thome.event.RuleAddedEvent] - Rule '307fc459-78e2-4c9d-a10f-1eda79deb69a' has been added.
2018-04-19 00:33:51.072 [.event.RuleStatusInfoEvent] - 307fc459-78e2-4c9d-a10f-1eda79deb69a updated: INITIALIZING
2018-04-19 00:33:51.081 [.event.RuleStatusInfoEvent] - 307fc459-78e2-4c9d-a10f-1eda79deb69a updated: UNINITIALIZED (CONFIGURATION_ERROR): Validation of rule 307fc459-78e2-4c9d-a10f-1eda79deb69a has failed! Condition Type "core.ItemStateCondition" does not exist!
2018-04-19 00:33:51.688 [.event.RuleStatusInfoEvent] - 307fc459-78e2-4c9d-a10f-1eda79deb69a updated: INITIALIZING
2018-04-19 00:33:51.693 [.event.RuleStatusInfoEvent] - 307fc459-78e2-4c9d-a10f-1eda79deb69a updated: UNINITIALIZED (CONFIGURATION_ERROR): Validation of rule 307fc459-78e2-4c9d-a10f-1eda79deb69a has failed! Condition Type "core.ItemStateCondition" does not exist!


Your item should be:

String Main_Temp_json "Main Temp [JSONPATH($.AM2301.Temperature):%s °F]" { mqtt="<[OH2:tele/Living_Temp/SENSOR:state:JSONPATH($AM2301.Temperature)]"}
Number Main_Temp  "Main Temp [%.1f °F]" { mqtt="<[OH2:tele/Living_Temp/SENSOR:state:JSONPATH($.AM2301.Temperature)]"}

And you don’t need the rule

1 Like

Thanks vzorglub! The temp is now showing up on the sitemap.

Would you mind explaining why I need both items subscribing to an mqtt topic?

You don’t, you had two items, so I corrected both

Understood. I appreciate the help!