During normal operation, controller:
CLI commands must be send via serial port with 115200 baud rate / 8N1 params: 8 data bits, no parity bit, 1 stop bit.
Example via shell:
> stty -f /dev/cu.usbmodem146101 ispeed 115200 ospeed 115200 -parenb cs8 cstopb > echo "ip" > /dev/cu.usbmodem146101 > cat /dev/cu.usbmodem146101
Same can be done via GUI e.g. from Arduino IDE (serial monitor). Serial port must be configured (MacOSX config file ~/Library/Arduino15/preferences.txt)
serial.databits=8 serial.stopbits=1 serial.parity=N serial.debug_rate=115200 serial.line_ending=1
The example of config files you can find in config folder Note: in real configs comments are not allowed Below is brief explanation of basic configuration values:
{ "mqtt":["mqtt_id","host",port,"user","pass"], //ip address/name and client id of mqtt broker. Port, user, pass - are optional // 1-Wire configuration chapter. "device#":{"emit":"mqtt topic suffix to report temp. measurements", "item":"local ite$ "ow":{ "284811170400005B":{"emit":"t_entr"}, //reports temp to mqtt /myhome/s_out/t_entr "28FFF95533160459":{"emit":"t_bath1","item":"h_bath1"}, },
Every Lighthub's object are «item»: lamp, dimmer, termostat, relay, led etc item is accessible via mqtt bus as /myhome/in/itemname
#define I_TYPE 0 //Type of item #define I_ARG 1 //Chanel-type depended argument or array of arguments (pin, address etc) #define I_VAL 2 //Latest preset (int or array of presets) #define I_CMD 3 //Latest CMD received #define I_EXT 4 //Chanell-depended extension - array
There are two mandatory elements in item's array: type and address 1-st element of array is item type
# Item types:
# of type | ID | Note | Parameters |
---|---|---|---|
0 | DIMMER | DMX out 1 ch | |
1 | RGBW | DMX out 4 ch | |
2 | RGB | DMX out 3 ch | |
3 | PWM | PWM output directly to PIN | |
4 | MODBUS | Modbus AC Dimmer | |
5 | THERMO | Simple ON/OFF thermostat | |
6 | RELAY | ON_OFF relay output | |
7 | GROUP | Group pseudochannel | |
8 | VCTEMP | Vacom PID thermo - regulator (Ventilation set) | |
9 | VC | Vacom modbus motor regulator | |
10 | AC 10 | Air Conditioner Haier | |
11 | SPILED | SPI LED | |
12 | MOTOR | Motorized air gateway | |
13 | PID | PID regulator | |
14 | MBUS | Universal Modbus channel | |
18 | MULTIVENT | Multiroom ventilation set |
Address is channel depended. Pin# for relay, DMX address for DMX-512 channel, array for Modbus channel. In case of DMX item note that addressees are continuous numbering between decoders and start address of each decoders configurable by jumpers. E.g. if you have two 24-ch decoders and want to control all 48 channels then you must set address «1» on the first decoder and «25» on the second.
"items":{ // Example of array "all":[7,["h_entr","h_bath1","h_bath2","h_balk1","h_balk2","h_boil1","h_boil2","h_polotenc","spots_en"]] // Examples of Thermostate items [type,pin,temperatureC] "h_bath1":[5,24,33], "h_bath2":[5,34,32], "h_entr" :[5,35,32], "h_balk1":[5,25,28], "h_balk2":[5,27,28], // Examples of relay items [type, pin, preset, default command] "h_boil1":[6,23], // simple relay on pin 23 "h_boil2":[6,28,1,1], // relay, turned on by default (after reboot) "h_polotenc":[6,26,1,1], "spots_en":[6,22,1,1], "light_en":[6,29,1,1], "water":[6,36,1,1] },
// "in" syntax // "pin": { "T":type, "emit":"out_emit", item:"out_item", "scmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd": "ON,OFF,TO$ // //Switch/Restore all //"pin": { "T":1, "emit":"/myhome/in/all", item:"local_all", "scmd": "OFF", "rcmd": "RESTORE"} // //Normal (not button) Switch (toggled mode) //"pin": { "T":1, "emit":"/light1", item:"light1", "scmd": "TOGGLE", "rcmd": "TOGGLE"} //not deployed yet //Normal (not button) Switch //"pin": { "T":0, "emit":"/light1", item:"light1", "scmd": "ON", "rcmd": "OFF"} // or // "pin": { "T":0, "emit":"/light1", item:"light1"} //or // "pin": { "emit":"/light1", item:"light1"} //1-Button dimmer //not deployed yet //"pin": { "T":1, "emit":"/light1", item:"light1", "scmd": "ON", srcmd:"INCREASE",rrcmd:"DECREASE", "rcmd": "OFF"} //2-Buttons dimmer //"pin1": { "T":0, "emit":"/light1", item:"light1", "scmd": "ON", repcmd:"INCREASE"} //"pin2": { "T":0, "emit":"/light1", item:"light1", "scmd": "OFF", repcmd:"INCREASE"} "in":{ "41":{"T":0,"emit":"/myhome/in/all","scmd":"HALT","rcmd":"REST"}, //Emits HALT on close contact, REST on open "37":{"item":"spots_en","scmd":"TOGGLE","rcmd":"TOGGLE"}, //Toggle on/off local spots every changing state of PIN "38":{"emit":"/myhome/in/light","scmd":"TOGGLE","rcmd":"TOGGLE"}, //Toggle remote light on local switch "40":{"T":1,"emit":"/myhome/out/all","scmd":"HALT","rcmd":"REST"}, ////not deployed yet "39":{"emit":"/myhome/s_out/water_leak"} } }
Currently, Lighthub working with Vacom 10 frequency driver (from Danfos) via Modbus RTU and allows control frequency (item type = 9) and internal PID controller (item type = 8 - used for Temperature control) Additionally, performing polling parameters from Vacom and publishing in JSON format to status MQTT Topic
If you just need to write some Modbus register on MQTT command & poll it back with simple scaling - you can use item type #4 (Modbus dimmer)
Config example (refer https://github.com/anklimov/lighthub/wiki/Configuring):
{ "items": { "bth1":[4,[96,0,0,255]] }, "mqtt":["lighthub-07","m2m.eclipse.org"] }
Note: this config example available at URL http://lazyhome.ru/de-ad-be-ef-fe-07.config.json - so just set mac address of device by command “mac de:ad:be:ef:fe:07” for test.
Item notation:
Mask: if mask == 1 - Value comes to most significant byte of 16 bit register word, another byte = 0xff if mask == 0 - Value comes to least significant byte of 16 bit register word, another byte = 0xff any other mask - put Value as 16 bit word without any modification if mask == -1 (or parameter omitted) - no register polling
Note: Serial line parameters for itemtype 4 is 9600:8N1 (look for “dimPar» and “MODBUS_SERIAL_BAUD” definitions in config.h if you need to change it)