25.09.2023, 19:11
Hi, small script, which will help to create json profile for daikin modbus interface DIII (D3)
just fill the ac_zones table according to your room names
ac_zones[i][j]
i - line(1-4)
j - ac unit (00-15)
and then download profile fromlocal ftp server using "ftp" login. you can add more registers if it is needed
Code:
require('json')
data = {
manufacturer = "daikin",
description = "modbus gateway",
mapping = {
{
}
}
}
str = json.encode(data)
--log(str)
--io.writefile('home/ftp/modbus.json', str)
ac_zones = {
[1] ={
[0] = '2_15 Мастер спальня',
[1] = '2_01 Прихожая',
[2] = '2_07 Cпальня 2',
[3] = '2_02 Cпальня 1'
},
[2] ={
[0] = '1_18 Каминная',
[1] = '1_16 Холл 2',
[2] = '1_09 Массажная',
[3] = '1_08 Спортзал',
[4] = '1_04 Гостиная',
[5] = '1_05 кухн'
},
[3] ={
[0] = '0_06-1 Бар',
[1] = '0_06-2 Бар',
[2] = '0_03 ДК'
},
}
function ac_mapping_create (zones_table)
mapping_table = {}
for line, zones in pairs(zones_table) do
for unit, name in pairs(zones) do
-- статус подключения
table.insert(mapping_table,
{
name = name.." - connection",
type = "inputregister",
bus_datatype = "bool",
address = 1 + (line-1),
datatype = "int16",
value_bitmask = 2^(unit)
}
)
-- ошибка коммуникации
table.insert(mapping_table,
{
name = name.." - communication error",
type = "inputregister",
bus_datatype = "bool",
address = 5 + (line-1),
datatype = "int16",
value_bitmask = 2^(unit)
}
)
-- уставка
table.insert(mapping_table,
{
name = name.." - setpoint ctrl",
type = "register",
bus_datatype = "temperature",
address = 2002 + (line-1)*16*3 + unit*3,
datatype = "int16",
writable = 1,
write_only = 1,
value_multiplier = 0.1
}
)
table.insert(mapping_table,
{
name = name.." - setpoint status",
type = "inputregister",
bus_datatype = "temperature",
address = 2002 + (line-1)*16*6 + unit*6,
datatype = "int16",
value_multiplier = 0.1
}
)
-- текущая
table.insert(mapping_table,
{
name = name.." - Room temp",
type = "inputregister",
bus_datatype = "temperature",
address = 2004 + (line-1)*16*6 + unit*6,
datatype = "int16",
value_multiplier = 0.1
}
)
-- opermode
table.insert(mapping_table,
{
name = name.." - Operation mode status",
type = "inputregister",
bus_datatype = "uint8",
address = 2001 + (line-1)*16*6 + unit*6,
datatype = "int16",
value_bitmask = 15
}
)
table.insert(mapping_table,
{
name = name.." - Operation mode ctrl",
type = "register",
bus_datatype = "uint8",
address = 2001 + (line-1)*16*3 + unit*3,
datatype = "int16",
writable = 1,
write_only = 1,
value_bitmask = 15,
write_bitmask = true
}
)
--fan st
table.insert(mapping_table,
{
name = name.." - fan speed status",
type = "inputregister",
bus_datatype = "uint8",
address = 2000 + (line-1)*16*6 + unit*6,
datatype = "int16",
value_bitmask = 28672
}
)
table.insert(mapping_table,
{
name = name.." - fan status",
type = "inputregister",
bus_datatype = "uint8",
address = 2000 + (line-1)*16*6 + unit*6,
datatype = "int16",
value_bitmask = 32
}
)
-- power st
table.insert(mapping_table,
{
name = name.." - onoff status",
type = "inputregister",
bus_datatype = "uint8",
address = 2000 + (line-1)*16*6 + unit*6,
datatype = "int16",
value_bitmask = 1
}
)
-- controls
table.insert(mapping_table,
{
name = name.." - fan speed ctrl",
type = "register",
bus_datatype = "uint8",
address = 2000 + (line-1)*16*3 + unit*3,
datatype = "int16",
writable = 1,
write_only = 1,
value_bitmask = 28672,
write_bitmask = true
}
)
table.insert(mapping_table,
{
name = name.." - fan flag ctrl",
type = "register",
bus_datatype = "uint8",
address = 2000 + (line-1)*16*3 + unit*3,
datatype = "int16",
writable = 1,
write_only = 1,
value_bitmask = 240,
write_bitmask = true
}
)
table.insert(mapping_table,
{
name = name.." - onoff ctrl",
type = "register",
bus_datatype = "bool",
address = 2000 + (line-1)*16*3 + unit*3,
datatype = "int16",
writable = 1,
write_only = 1,
value_bitmask = 1,
write_bitmask = true
}
)
end
end
return mapping_table
end
data.mapping = ac_mapping_create(ac_zones)
str = json.encode(data)
log(io.writefile('home/ftp/KP1_DAIKIN_modbus.json', str))
ac_zones[i][j]
i - line(1-4)
j - ac unit (00-15)
and then download profile fromlocal ftp server using "ftp" login. you can add more registers if it is needed