MQTT items

Dear all,
so now, latest part of my adventure… ESP8266 (NodeMCU) with ESPEasy, a reed switch, Mosquitto MQTT broker, OH2…

I can get OH2 to display the sensor:

Kind-of working:

Number MQTTLED { mqtt="<[mosquitto:/ESP_Easy/reed/contact:state:default]" }

2017-12-26 11:25:10.947 [vent.ItemStateChangedEvent] - MQTTLED changed from NULL to 0
2017-12-26 11:26:38.025 [vent.ItemStateChangedEvent] - MQTTLED changed from 0 to 1

Kind-of-point is that the sitemap value is not refreshed, I have to hit F5 on the browser to see it.

Not working:
Number Reed “State [%s]” {mqtt="<[mosquitto:ESP_Easy/reed/contact:state:default]"}

Text item=Reed label=“Test [%s]”

a) why does the first item work but not the second?
b) do I need the leading “/” in front of ESP_Easy.
Online many examples seem to contain it, but the binding tutorial does not.

Thanks as always


I subscribed via terminal to all messages to have a look out and get:


So I guess for some reason, in my setup the leading forward slash is needed.
(And it makes sense, I check my ESP_Easy config and it had the leading slash).

Next 2 questions:
a) Why BASIC UI does not update in real-time (or with a minor lag)?
b) The reed switch is contacted to my gas-meter.
1 Rotation of the gas-meter disc = X m3 of Gas flow.

I want to define a variable that accumulates number of rotations (i.e. number of state changes from 0 to 1)
Ideally logging it and plotting.

Any advice?

Mine don’t have a leading forward slash.
Also, with the second one, you’ve asked for a string item [%s]” to be displayed rather than a number item

Why are you using a number item type for a contact rather than a contact item type as in:

Contact MQTTLED “State [%s]”  { mqtt="<[mosquitto:ESP_Easy/reed/contact:state:default]" }
Contact Reed “State [%s]” {mqtt="<[mosquitto:ESP_Easy/reed/contact:state:default]"}

Now the UI works well. Thanks:

Text item=ReedSwitch1 icon="switch" label="Test [%s]"

Number ReedSwitch1 "State" <switch> (BS, gSensors) {mqtt="<[mosquitto:/ESP_Easy/reed/contact:state:default]"}

Now for logging and plotting… plot continues (pun intended)

1 Like

Getting there, now I have:

var GasCount = 0

rule "test"
		Item ReedSwitch1 changed from 0 to 1
		GasCount = GasCount + 1

Number ReedSwitch1 “State” (BS, gSensors) {mqtt="<[mosquitto:/ESP_Easy/reed/contact:state:default]"}
Number GasCounter “Light sensor 1 [%.1f m3]”

Text item=ReedSwitch1 icon=“switch” label="Test [%s]"
Text item=GasCounter label=“Light sensor 1 [%.0f m3]”