(28.09.2017, 20:22)Erwin van der Zwart Wrote: Hi,I've tried to modify and seems it works
Yes i could, but i don't see the point (:
You can change grp.address = '1/1/' .. counter to grp.address = '1/2/' .. counter and run it again, the script checks already if a object is already mapped and skips it then, so it will resume on the unmapped objects.
If you have 900 objects just run it 4 times and change the grp.address range between each run.
also add script.disable(_SCRIPTNAME) at the end of the above script to avoid it from running multiple times when using it from a resident script
BR,
Erwin
Code:
-- Select all entrys from DB inside table 'modbus_mapping'
-- "id", "internal_id", "device", "name", "active", "bus_write", "bus_address", "bus_datatype", "internal", "type", "value_delta","value_base","value_multiplier","value_bitmask","value_nan","value_conv","value_custom","units","address","address_scale","read_count","read_offset","read_swap","datatype","writable","write_only","write_multiple"
query = 'SELECT * FROM modbus_mapping'
counter = 0
for _, mapping in ipairs(db:getall(query)) do
if mapping.bus_address == "" or mapping.bus_address == nil then
mid_group = math.floor(counter/256)
grp_address = '32/'..mid_group..'/' .. (counter - 256*mid_group)
log(grp_address)
if counter < 2047 then
dec_grp_address = knxlib.encodega(grp_address)
address = grp.create({
datatype = mapping.datatype,
address = grp_address,
name = mapping.name,
comment = 'Auto mapped by script',
units = mapping.units,
tags = {},
})
counter = counter + 1
db:update('modbus_mapping', { bus_address = dec_grp_address, bus_write = 1, value_delta = 0.1, value_custom = 'Auto mapped by script' }, { id = mapping.id })
end
end
end
log('done')
script.disable(_SCRIPTNAME)
this script worked about 1 minute
(29.09.2017, 07:37)toujour Wrote: Hi to Everybody,I think there is another simple way
I like your scripts !!
I have a problem with only one object in modbus mapping profile, please see the image in the attachment.
I want change the COIL 192 to COIL 191 ( I forgot it in the profile )
Can I use a script to change only this point ? I have more then 500 point in this modbus device.
Thanks in Advance !
Alberto
You can create additional profile for your modbus device only with coil 191.