Post your best Lua script examples here

User avatar
By ax8814
#52807 :?: Hi to everybody, i'm a bit newbie with ESPxxxx and Lua and overall I don't speak english as I would like to. My question is in regard of using 2 pins of my ESP-12E to trigger a 2 channel relay and a third pin to get data from a dht11 temperature sensor. I use OPENHAB to manage light and temperature and it is working perfectly ok as long as I run one application at a time. I have a Lua script which is listening at a topic from my MQTT server for managing the relays and everything is ok. I also have a Lua script to publish dht11 data on MQTT and get it displayed in OpenHab and it is also work super. But now after 2 weeks I can't figure out how to create a loop that will allways listening for a LIGHTS command and in the same time will send temperature data every 30 seconds or 60 seconds.
Thanks you for your help if what I have write is clear enought

Openhab 1.8.7 running on my Raspberry pi 3 revB
MQTT server = Mosquitto 3.1 on my raspberry Pi
ESP-12E - nodeMCU custom build by frightanic.com branch: dev
commit: b21b3e08aad633ccfd5fd29066400a06bb699ae2
SSL: true
modules:adc,adxl345,cjson,dht,encoder,enduser_setup,file,gpio,http,i2c,mdns,mqtt,net,node,pwm,rotary,sntp,tmr,uart,wifi
build built on: 2016-07-19 13:35
powered by Lua 5.1.4 on SDK 1.5.4(baaeaebb)