Инструменты пользователя

Инструменты сайта


конфигурирование

Это старая версия документа!


# Boot sequence:

* Trying to load JSON config from NVRAM. If config is valid JSON structure - start to operating (to avoid dependance from network and allow local control) * Trying to retrieve MAC address, stored in NVRAM. If ok - using retrieved MAC. If not - using CUSTOM_FIRMWARE_MAC (see compilers directives). If not configured - using hardcoded DEFAULT_FIRMWARE_MAC = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0} * Starting LAN with DHCP or with static ip if configured * Trying to load JSON config from address «http://MY_CONFIG_SERVER/12-12-12-12-12-12.config.json», where «12-12….12» is controller's MAC address and MY_CONFIG_SERVER - compiler's directive. If not configured = lazyhome.ru used * After parsing of loaded config, performing re-initialization of objects, except number of DMX channels. There is possible to store loaded config in NVRAM after some testing using «save» cli command. * Connecting to MQTT server according stored or retrieved config. * Subscribing to OUTTOPIC (/myhome/s_out/# by default) for 5 sec. Retrieving and executing all persistent topic (restore recent values) * Unsubscribe from OUTTOPIC, Subscribe for INTOPIC (/myhome/in/# by default) and start processing normal incoming event flow

# Operation During normal operation, controller:

* Accepting incoming MQTT message flow and retrieving item name from topic name. For example, /myhome/in/item1 will control «item1» * Controlling items. * Most commands, accepted on INTOPIC passed throw to OUTTOPIC after interpretation. Interpretation is converting of high level commands like ON OFF HALT REST to low-level commands with real values. OUTTOPIC publishing uses «persistent» flag to allow retrieving recent status from MQTT broker after restart of controller * Polling: Normally, Modbus devices and 1-wire thermometers are polled with reasonable interval. Retrieved values are publishing to OUTTOPIC

# Useful CLI commands:

* mac 11:22:33:44:55:66 - writing custom MAC address to NVRAM * save - writing currently loaded config from RAM to NVRAM * get <servername> - retrieve config from server and store servername to NVRAM (default servername: lazyhome.ru) * ip [ip[ dns[ gw[ subnet]]]] - configure and save to NVRAM static ip. if no parameters - DHCP will be used * load - load config from NVRAM * kill - test watchdog timer (normally, causes reboot)

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| DMX|DMX out: 1,3 (RGB) or 4 (RGBW) channels|Single DMX chan# or Array of channels for RED, GREEN, BLUE and (optional) WHITE lamps| |1| RGBW |DMX out 4 ch|Start DMX address for 4 sequenlial channels | |2| RGB |DMX out 3 ch|Start DMX address for 3 sequenlial channels | |3| PWM |PWM out: 1,3 (RGB) or 4 (RGBW) channels|Single PWM pin# or Array of pin#| |4| MODBUS|Modbus AC Dimmer|see Modbus chapter below| |5| THERMO|Simple ON/OFF thermostat|| |6| RELAY |ON_OFF relay output|| |7| GROUP |Group pseudochannel|Array of item names| |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 ``` «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]
       },

```

# Inputs configuration chapter

``` «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"}
       }

} ```

# Modbus channel

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: * 4 - Modbus dimmer item type

* Param1: = 96 - Decimal address of modbus device * Param2: = 0 - Modbus register to write (and read while polling) * Param3: = 0 - mask (optional. Default value “-1” - see below for explanations) * Param4:= 255 - Maximum Value for scaling MQTT input value = 100 to register value (Optional. Default MaxValue 0x3f. It is equivalent of “100« on input. If value == 0 - no scaling)

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)

конфигурирование.1631265443.txt.gz · Последнее изменение: 2021/09/10 12:17 — 216.244.66.245