Setpoint in OpenHAB integrated with emoncms

Hello,

I understood the basics of how i can publish some values to the “tx” entries of a node (i have 4 tx variables):
mosquitto_pub -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emonhub/tx/29/values’ -m “7,1,7,2”

Now I wanted to do the same from OpenHAB.
Number 29aq_phMin “phMin [%.1f pH]” { mqtt=">[mosquitto:emonub/tx/29/ … hmm

well … not sure what to write because i do not want to send all 4 values at once but only one of the tx values (named phMin).
Maybe something like:
Number 29aq_phMin “phMin [%.1f pH]” { mqtt=">[mosquitto:emonub/29aq/phMin … hmm

again I’m not sure what to write after the topic - because is not a command.

In sitemap I defined:
Setpoint item=29aq_phMin minValue=“6.7” maxValue=“6.8” step=“0.01”

Any idea? Any example?

Or for now it is only possible to use OpenHAB control for ON/OFF on lwrf topic?

I also got no message in emonhub when I do:
mosquitto_pub -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emon/29aq/phMax’ -m 7.1

While if i do:
mosquitto_pub -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emonhub/tx/29/values’ -m 7,1,7,2

I see (as expected):
2016-05-13 20:11:11,462 DEBUG MQTT Nodeid: 29 values: 7,1,7,2
2016-05-13 20:11:11,465 DEBUG MQTT 1880 sent TX packet: 29,188,2,100,0,188,2,200,0,s
2016-05-13 20:11:11,466 DEBUG MQTT 1880 Sent to channel’ : ToRFM12

Is currently possible to only send “tx” messages using “emonhub/” topic?

Thanks for info.
Marius

Hi Marius,

Before I try and answer your question, could you give me a bit of background? What are you trying to do? What are you trying to control?

I have an aquarium controller that is based on emontx + some relays.
I try to control certain parameters of the aquarium.
Right now the emontx is checking the ph in the aquarim and it injects CO2 if ph is too big.
The limits ph too big and ph too low are right now hardcoded in Arduino code.
I want that Arduino gets the values phMin and phMax from a different place.
I thought OpenHAB is a good place.
I expected:
OpenHAB → emonhub → RFM12 ---- (radio) -----> RFM12B → Arduino

Maybe I can give a try also to NodeRed.

Initially i used emoncms packetgen and it worked nearly perfect.

It is a very similar usecase with a thermostat where you want to control remotely the temperature. The thermostat will know how to keep the temperature constant by trying to use the setpoint temp from OpenHAB(?) and using (for example) a PID controller will try to keep the temperature constant. There is already a PID Library for arduino that works very well from my tests (it has also autocontrol features helping to self compute P,I,D values automatically).

OK cool, thanks for the info. Yes, posting to emonhub/rx should work. Does publishing running the following publish command result in a transmitted value? Can you receive the RF on your control node?

$ mosquitto_pub -u 'emonpi' -P 'emonpimqtt2016' -t 'emonhub/tx/29/values' -m "7,1,7,2"

Check emonhub.log to see if the data is being sent. A’s for openHAB I’m afraid I am no expert. I would recomend asking @ben.jones12 or posting on the OpenHAB forums https://community.openhab.org.

One of the reasons why we switched to using the new MQTT topic structure what that using CSV messages on MQTT topics is not really how MQTT was designed and it made it very difficult to subscribe in openhab to a single key value. It’s much easier with the new topic structure. See OpenHAB example config.

1 Like

Yes,if I execute:
$ mosquitto_pub -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emonhub/tx/29/values’ -m “7,1,7,2”

I get info in emonhub log:
2016-05-13 20:11:11,462 DEBUG MQTT Nodeid: 29 values: 7,1,7,2
2016-05-13 20:11:11,465 DEBUG MQTT 1880 sent TX packet: 29,188,2,100,0,188,2,200,0,s
2016-05-13 20:11:11,466 DEBUG MQTT 1880 Sent to channel’ : ToRFM12

but this did not happen if I execute:
mosquitto_pub -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emon/29aq/phMax’ -m 7.1

The two represents the same value:
[[29]]
nodename = 29aq
[[[rx]]]
names = temperature, filter, lights, co2coil, ph, heater, feeder, hh,mm
datacode = h
scales = 0.01,1,1,1,0.01,1,1,1,1
units = C,p,p,p,pH,p,p,p,p
[[[tx]]]
names = phMin, phMax, tempMin, tempMax
units = pH,pH,C,C
scales = 0.01,0.01,0.01,0.01
datacode = h

Even more interesting: Now if i try to publish something on ‘emonhub/tx/29/values’ i get not message on emoncms or emonhub logs - update: increased loglevel to debug and now i get the mesage

So you say normally i should be able to access emon/29aq/phMin not only emonhub/tx/29/values from openhab?

if i send a value using mosquito to emon/29aq/phMax => this is not sent to RFM2Pi
If i send all values (as a vector) to emonhub/tx/29/values => this is sent to RFM2Pi

Reasons are here:

This is restricted in on_message method of EmonHubMqttInterfacer.py as shown in diagram.

IMHO this is a show stopper for OpenHAB integration because you will always need to send all the sentpoints of a node from openHAB. It is impossible to send one single variable.

The emon topic does not support transmission, emon topic is used to post data to emoncms.

The transmission via RFM12B / RFM69CW has been neglected in favour of direct WiFi and MQTT control devices such as the ESP8266 WiFi-MQTT relay we are stocking on the shop.

Thx for all the valuable info.

I will give a try to ESP8266 too.

I updated the diagram if someone is interested: