WiFi , , , OpenHAB
MP3502.

ESP8266 DS18B20. Wi-Fi , , UDP. , . UDP OpenHAB.
«» , , .
:
OpenHAB
.
, , 1 .

- № 2
Wi-Fi- MP3502, ESP8266
1…99 , ( ) – 1…5 0, 1 . – 12 , 250 .
, C:\OpenHab\configurations. . configurations_testdive2.zip.
1.
. openhab.cfg . TCP/UDP , Wi-Fi.
2.
. , . . (, OpenHAB , localhost IP- OpenHAB ).


MP3502 Wi-Fi , testdrive.sitemap .

testdrive.Items :

3.
MP3500 . .items C:\OpenHab\configurations\items. , :
Group WIFI_3502 «MP3502 Wi-Fi » (gFF)
/* MP3502 WiFi — */
Number MP3502_T « :[ %.1f °C]» (WIFI_3502)
Number MP3502_T_UST « :[ %s °C]» (WIFI_3502)
Dimmer MP3502_InputU « T /[%.1f °C]» (WIFI_3502)
Dimmer MP3502_InputG « / [%.1f °C]» (WIFI_3502)
Switch MP3502_Set «» (WIFI_3502)
{ udp=">[OFF:192.168.2.108:7777:MAP(MP3502_Info.map)]" }
String MP3502_R « :[:%s]» (WIFI_3502)
, Item , NotePad . testrive.items.
. , . Items, , .
. Inems , TCP/UDP Binding !SetR0_1\r, . Item- OFF , OFF. ,
>[OFF:192.168.2.108:7777:MAP(MP3502_U_eco.map): Item- OFF > UDP :
192.168.2.108:7777 ,
MP3502_U_eco.map OFF.
MP3502_U_eco.map, C:\OpenHab\configurations\transform, , :
ON=!GetAll\r
OFF=!GetAll\r
, , Item Switch ON OFF c. . Switch .
Items.
: , ( ON OFF)
, :
/* Items "
Number MP3502_G « :[%s °C]»
String MP3502_Stat « : [:%s]» (WIFI_3502) { udp="<[192.168.2.108:*:'REGEX((.*))']" }
Switch MP3502_Request «MP3502 »
{ udp=">[ON:192.168.2.108:7777:MAP(MP3502_Info.map)]" }
Switch MP3502_SetU_eco «MP3502 „
{udp=“>[ON:192.168.2.108:7777:MAP(MP3502_U_eco.map)], >[OFF:192.168.2.108:7777:MAP(MP3502_U_eco.map)]» }
Switch MP3502_SetU_comf «MP3502 »
{udp=">[ON:192.168.2.108:7777:MAP(MP3502_U_comf.map)], >[OFF:192.168.2.108:7777:MAP(MP3502_U_comf.map)]" }
Switch MP3502_SetG_prec «MP3502 »
{udp=">[ON:192.168.2.108:7777:MAP(MP3502_G_prec.map)], >[OFF:192.168.2.108:7777:MAP(MP3502_G_prec.map)]" }
Switch MP3502_SetG_aprox «MP3502 „
{udp=“>[ON:192.168.2.108:7777:MAP(MP3502_G_aprox.map)], >[OFF:192.168.2.108:7777:MAP(MP3502_G_aprox.map)]» }
/* Items */. — (WIFI_3502).
, (Rules).

4.
. Testdrive.rules – , . - Dimmer, : , – , , :
rule «MP3502 Set U»
when
Item MP3502_InputU received command
then
var Number percent = 22 //
if(MP3502_InputU.state instanceof DecimalType) percent = MP3502_InputU.state as DecimalType //
if(receivedCommand==ON) percent = 22 // 22
if(receivedCommand==OFF) percent = 5 // 5
if(percent<1) percent = 5 // — , 5
if(percent>99) percent = 22 //...22
postUpdate(MP3502_InputU, percent); //
endDimmer INCREASE DECREASE ( ) . , . , :
if(receivedCommand==INCREASE) percent =percent + 1
if(receivedCommand==DECREASE) percent =percent — 1, 1 . , = 15, = 16 .. . 5-30 – , , Ctrl_C b Ctrl_V. C , . .
-, «» , … REGEX – . , OpenHAB , , () . , OFF, MP3502_U_eco.map OFF=!GetAll\r (. ).
String MP3502_Stat « : [:%s]» (WIFI_3502) {udp="<[192.168.2.108:*:'REGEX((.*))']"}
, OpenHAB , 7777, - 192.168.2.108:* ? , UDP … , !
, , :
rule «MP3502_Stat change»
when
Item MP3502_Stat changed //
then
var String sAppo = "" // sAppo
sAppo = MP3502_Stat.state.toString // sAppo , , — sExpr
var String sExpr = "^!LED(ON|OFF).*" // : ^ !LED (ON|OFF) — ON OFF : .* — . .
var Pattern pattern = Pattern::compile(sExpr) // sExpr
var Matcher matcher = pattern.matcher(sAppo) // Matcher — ( ) sAppo
matcher.find() // ,
var tmp = matcher.group(1) // tmp ,
postUpdate(MP3502_R, tmp ) // Item MP3502_R tmp,
tmp="" //«»… ..
! , // .
, !
! , COM-
MQTT.
:
Miklebor