04.06.2020, 08:00
You need to modify the profile to allow raw value to be written to the control register.
You will also need 3 objects: on/off (bool), fan direction (1 byte unsigned), fan volume (either bool or 1 byte unsigned depending on 2 or 3 step fan)
All objects must have the same tag assigned to them, then you need to create an event script attached to this tag.
Change group addresses as needed, 1/1/4 is the group that is mapped to control register of ModBus device.
Code:
{ "name": "on_off_status_00", "bus_datatype": "bool", "type": "inputregister", "address": 2000, "value_bitmask": 0x0001},
{ "name": "set_temp_status_00", "bus_datatype": "float16", "type": "inputregister", "address": 2002, "value_multiplier": 0.1, "units": "C" },
{ "name": "act_temp_status_00", "bus_datatype": "float16", "type": "inputregister", "address": 2004, "value_multiplier": 0.1, "units": "C" },
{ "name": "control_00", "bus_datatype": "uint16", "type": "register", "writable": 1, "write_only": true, "address": 2000 },
{ "name": "set_mode_00", "bus_datatype": "uint8", "type": "register", "writable": 1, "write_only": true, "address": 2001 },
{ "name": "set_temp_00", "bus_datatype": "float16", "type": "register", "writable": 1, "write_only": true, "value_multiplier": 0.1, "address": 2002, "units": "C"},
You will also need 3 objects: on/off (bool), fan direction (1 byte unsigned), fan volume (either bool or 1 byte unsigned depending on 2 or 3 step fan)
All objects must have the same tag assigned to them, then you need to create an event script attached to this tag.
Change group addresses as needed, 1/1/4 is the group that is mapped to control register of ModBus device.
Code:
onoff = grp.getvalue('1/1/1') and 1 or 0
direction = grp.getvalue('1/1/2')
volume = grp.getvalue('1/1/3')
if direction > 7 or direction == 5 then
direction = 6
end
if type(volume) == 'boolean' then
volume = volume and 1 or 5
elseif volume ~= 1 and volume ~= 3 and volume ~= 5 then
volume = 1
end
value = bit.bor(
onoff,
bit.lshift(6, 4),
bit.lshift(direction, 8),
bit.lshift(volume, 12)
)
grp.update('1/1/4', value)