added migrated 2.x add-ons
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Useful commands to create files used by the binding from Nibe ModbusManager CSV files
|
||||
|
||||
Command to convert Nibe CSV file character set to UTF-8:
|
||||
```iconv -f iso-8859-1 -t utf-8 F1X45.csv > F1X45_utf8.csv```
|
||||
|
||||
Command to create channel-types from CSV file (all channels are marked as advanced, so remove it manually from desired channels):
|
||||
```awk -f create_channel_types.awk F1X45_utf8.csv > F1X45.xml```
|
||||
|
||||
Command to create all channels from CSV file:
|
||||
```awk -f create_channels.awk F1X45_utf8.csv > F1X45-all-channels.xml```
|
||||
|
||||
Command to create dedicated channels from CSV file:
|
||||
```awk -f create_sensor_channels.awk F1X45_utf8.csv > F1X45-sensor-channels.xml```
|
||||
```awk -f create_settings_channels.awk F1X45_utf8.csv > F1X45-settings-channels.xml```
|
||||
|
||||
Command to create java variableInformation from CSV file:
|
||||
```awk -f create_java_variable_information.awk F1X45_utf8.csv > F1X45-variable-information.txt```
|
||||
|
||||
Command to crate READ.md channel tables:
|
||||
```awk -f create_readme_channel_table.awk F1X45_utf8.csv > F1X45-readme-channel-table.txt```
|
||||
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
|
||||
BEGIN{
|
||||
FS=";"
|
||||
|
||||
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
print "<thing:thing-descriptions bindingId=\"nibeheatpump\""
|
||||
print "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
||||
print "xmlns:thing=\"https://openhab.org/schemas/thing-description/v1.0.0\" "
|
||||
print "xsi:schemaLocation=\"https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd\">"
|
||||
print ""
|
||||
}
|
||||
NR>5{
|
||||
|
||||
title=$1
|
||||
info=$2
|
||||
id=$3
|
||||
unit=$4
|
||||
size=$5
|
||||
factor=$6
|
||||
min=$7
|
||||
max=$8
|
||||
default=$9
|
||||
mode=$10
|
||||
|
||||
gsub("\"", "", title)
|
||||
gsub("&","\\&", title)
|
||||
gsub(/</,"\\<", title)
|
||||
gsub(">","\\>", title)
|
||||
|
||||
gsub("\"", "", unit)
|
||||
|
||||
gsub("\"", "", info)
|
||||
gsub("&","\\&", info)
|
||||
gsub(/</,"\\<", info)
|
||||
gsub(">","\\>", info)
|
||||
|
||||
optionsData=info
|
||||
delete keys
|
||||
delete values
|
||||
|
||||
# parse options from info field
|
||||
if (index(optionsData, "=") > 0)
|
||||
{
|
||||
gsub(",", "=", optionsData)
|
||||
gsub(" ", "=", optionsData)
|
||||
|
||||
key=""
|
||||
value=""
|
||||
keyCount=1
|
||||
|
||||
count = split(optionsData, t, "=")
|
||||
|
||||
for (i = 0; ++i <= count;)
|
||||
{
|
||||
if (t[i] ~ /^[0-9]+$/)
|
||||
{
|
||||
if (key != "")
|
||||
{
|
||||
if (trim(value) == "")
|
||||
{
|
||||
values[keyCount-1] = values[keyCount-1] " " key
|
||||
}
|
||||
else
|
||||
{
|
||||
keys[keyCount] = trim(key)
|
||||
values[keyCount] = trim(value)
|
||||
keyCount++
|
||||
key=""
|
||||
value=""
|
||||
}
|
||||
}
|
||||
|
||||
key = t[i]
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key != "")
|
||||
value = value " " t[i]
|
||||
}
|
||||
}
|
||||
|
||||
if (key != "")
|
||||
{
|
||||
keys[keyCount] = trim(key)
|
||||
values[keyCount] = trim(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf(" <channel-type id=\"type-%s\" advanced=\"true\">\n", id)
|
||||
|
||||
if (min == 0 && max == 1)
|
||||
{
|
||||
printf(" <item-type>Switch</item-type>\n")
|
||||
printf(" <label>%s</label>\n", title)
|
||||
printf(" <description>%s</description>\n", info)
|
||||
|
||||
if (mode == "R")
|
||||
readOnly="true"
|
||||
else
|
||||
readOnly="false"
|
||||
|
||||
printf(" <state readOnly=\"%s\"></state>\n", readOnly)
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keys[1] != "")
|
||||
printf(" <item-type>String</item-type>\n")
|
||||
else
|
||||
printf(" <item-type>Number</item-type>\n")
|
||||
|
||||
printf(" <label>%s</label>\n", title)
|
||||
printf(" <description>%s</description>\n", info)
|
||||
|
||||
if (min == 0 && max == 0)
|
||||
{
|
||||
min="0";
|
||||
if (size == "u8")
|
||||
max="255"
|
||||
if (size == "u16")
|
||||
max="65535"
|
||||
if (size == "u32")
|
||||
max="4294967295"
|
||||
|
||||
if (size == "s8")
|
||||
{
|
||||
min="-128"
|
||||
max="127"
|
||||
}
|
||||
if (size == "s16")
|
||||
{
|
||||
min="-32767"
|
||||
max="32767"
|
||||
}
|
||||
if (size == "s32")
|
||||
{
|
||||
min="-2147483648"
|
||||
max="2147483647"
|
||||
}
|
||||
}
|
||||
|
||||
if (factor == 1)
|
||||
pattern = "%d"
|
||||
if (factor == 10)
|
||||
pattern = "%.1f"
|
||||
if (factor == 100)
|
||||
pattern = "%.2f"
|
||||
if (factor == 1000)
|
||||
pattern = "%.3f"
|
||||
|
||||
if (unit != "")
|
||||
pattern = pattern " " unit
|
||||
|
||||
if (mode == "R")
|
||||
printf(" <state pattern=\"%s\" readOnly=\"true\">\n", pattern)
|
||||
else
|
||||
printf(" <state min=\"%s\" max=\"%s\" step=\"1\" pattern=\"%s\" readOnly=\"false\">\n", min, max, pattern)
|
||||
|
||||
if (keys[1] != "")
|
||||
{
|
||||
printf(" <options>\n")
|
||||
for (x = 1; x <= keyCount; x++)
|
||||
printf(" <option value=\"%s\">%s</option>\n", keys[x], values[x])
|
||||
printf(" </options>\n")
|
||||
}
|
||||
printf(" </state>\n")
|
||||
}
|
||||
|
||||
printf(" </channel-type>\n")
|
||||
}
|
||||
END{
|
||||
print ""
|
||||
print "</thing:thing-descriptions>"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
|
||||
BEGIN{
|
||||
FS=";"
|
||||
}
|
||||
NR>5{
|
||||
|
||||
title=$1
|
||||
info=$2
|
||||
id=$3
|
||||
unit=$4
|
||||
size=$5
|
||||
factor=$6
|
||||
min=$7
|
||||
max=$8
|
||||
default=$9
|
||||
mode=$10
|
||||
|
||||
gsub("\"", "", title)
|
||||
gsub("\"", "", info)
|
||||
gsub("\"", "", unit)
|
||||
|
||||
printf(" <channel id=\"%s\" typeId=\"type-%s\"/>\n", id, id)
|
||||
}
|
||||
END{
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
|
||||
BEGIN{
|
||||
FS=";"
|
||||
}
|
||||
NR>5{
|
||||
|
||||
title=$1
|
||||
info=$2
|
||||
id=$3
|
||||
unit=$4
|
||||
size=$5
|
||||
factor=$6
|
||||
min=$7
|
||||
max=$8
|
||||
default=$9
|
||||
mode=$10
|
||||
|
||||
gsub("\"", "", title)
|
||||
gsub("\"", "", info)
|
||||
gsub("\"", "", unit)
|
||||
|
||||
if (mode == "R")
|
||||
type="Sensor"
|
||||
else
|
||||
type="Setting"
|
||||
|
||||
printf "put(%s, new VariableInformation(%4s, NibeDataType.%-3s, Type.%-8s, \"%s\"));\n", id, factor, toupper(size), type, title
|
||||
}
|
||||
END{
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
|
||||
BEGIN{
|
||||
FS=";"
|
||||
|
||||
print "| Channel Type ID | Item Type | Min | Max | Type | Description | Values |"
|
||||
print "|-----------------|--------------|--------------|--------------|---------|-------------------------------------|--------------------------------|"
|
||||
}
|
||||
NR>5{
|
||||
|
||||
title=$1
|
||||
info=$2
|
||||
id=$3
|
||||
unit=$4
|
||||
size=$5
|
||||
factor=$6
|
||||
min=$7
|
||||
max=$8
|
||||
default=$9
|
||||
mode=$10
|
||||
|
||||
gsub("\"", "", title)
|
||||
gsub("\"", "", info)
|
||||
gsub("\"", "", unit)
|
||||
|
||||
optionsData=info
|
||||
delete keys
|
||||
delete values
|
||||
|
||||
# parse options from info field
|
||||
if (index(optionsData, "=") > 0)
|
||||
{
|
||||
gsub(",", "=", optionsData)
|
||||
gsub(" ", "=", optionsData)
|
||||
|
||||
key=""
|
||||
value=""
|
||||
keyCount=1
|
||||
|
||||
count = split(optionsData, t, "=")
|
||||
|
||||
for (i = 0; ++i <= count;)
|
||||
{
|
||||
if (t[i] ~ /^[0-9]+$/)
|
||||
{
|
||||
if (key != "")
|
||||
{
|
||||
if (trim(value) == "")
|
||||
{
|
||||
values[keyCount-1] = values[keyCount-1] " " key
|
||||
}
|
||||
else
|
||||
{
|
||||
keys[keyCount] = trim(key)
|
||||
values[keyCount] = trim(value)
|
||||
keyCount++
|
||||
key=""
|
||||
value=""
|
||||
}
|
||||
}
|
||||
|
||||
key = t[i]
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key != "")
|
||||
value = value " " t[i]
|
||||
}
|
||||
}
|
||||
|
||||
if (key != "")
|
||||
{
|
||||
keys[keyCount] = trim(key)
|
||||
values[keyCount] = trim(value)
|
||||
}
|
||||
}
|
||||
|
||||
if (min == 0 && max == 1)
|
||||
{
|
||||
channelType="Switch"
|
||||
|
||||
if (mode == "R")
|
||||
readOnly="true"
|
||||
else
|
||||
readOnly="false"
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keys[1] != "")
|
||||
channelType="String"
|
||||
else
|
||||
channelType="Number"
|
||||
|
||||
if (min == 0 && max == 0)
|
||||
{
|
||||
min="0";
|
||||
if (size == "u8")
|
||||
max="255"
|
||||
if (size == "u16")
|
||||
max="65535"
|
||||
if (size == "u32")
|
||||
max="4294967295"
|
||||
|
||||
if (size == "s8")
|
||||
{
|
||||
min="-128"
|
||||
max="127"
|
||||
}
|
||||
if (size == "s16")
|
||||
{
|
||||
min="-32767"
|
||||
max="32767"
|
||||
}
|
||||
if (size == "s32")
|
||||
{
|
||||
min="-2147483648"
|
||||
max="2147483647"
|
||||
}
|
||||
}
|
||||
|
||||
if (factor == 1)
|
||||
pattern = "%d"
|
||||
if (factor == 10)
|
||||
pattern = "%.1f"
|
||||
if (factor == 100)
|
||||
pattern = "%.2f"
|
||||
if (factor == 1000)
|
||||
pattern = "%.3f"
|
||||
|
||||
if (unit != "")
|
||||
pattern = pattern " " unit
|
||||
|
||||
vals = ""
|
||||
|
||||
if (keys[1] != "")
|
||||
{
|
||||
for (x = 1; x <= keyCount; x++)
|
||||
{
|
||||
if (vals != "")
|
||||
vals = vals ", "
|
||||
|
||||
vals = vals keys[x] "=" values[x]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (readOnly == "true")
|
||||
type="Sensor"
|
||||
else
|
||||
type="Setting"
|
||||
|
||||
printf("| %s | %s | %d | %d | %s | %s | %s |\n", id, channelType, min, max, type, title, vals)
|
||||
}
|
||||
END{
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
|
||||
BEGIN{
|
||||
FS=";"
|
||||
print "<channel-group-type id=\"Sensors\">"
|
||||
print " <label>Sensors</label>"
|
||||
print " <channels>"
|
||||
}
|
||||
NR>5{
|
||||
|
||||
title=$1
|
||||
info=$2
|
||||
id=$3
|
||||
unit=$4
|
||||
size=$5
|
||||
factor=$6
|
||||
min=$7
|
||||
max=$8
|
||||
default=$9
|
||||
mode=$10
|
||||
|
||||
gsub("\"", "", title)
|
||||
gsub("\"", "", info)
|
||||
gsub("\"", "", unit)
|
||||
|
||||
if (mode == "R")
|
||||
printf(" <channel id=\"%s\" typeId=\"type-%s\"/>\n", id, id)
|
||||
}
|
||||
END{
|
||||
print " </channels>"
|
||||
print "</channel-group-type>"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/awk -f
|
||||
|
||||
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
|
||||
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
|
||||
function trim(s) { return rtrim(ltrim(s)); }
|
||||
|
||||
BEGIN{
|
||||
FS=";"
|
||||
print "<channel-group-type id=\"Settings\">"
|
||||
print " <label>Settings</label>"
|
||||
print " <channels>"
|
||||
}
|
||||
NR>5{
|
||||
|
||||
title=$1
|
||||
info=$2
|
||||
id=$3
|
||||
unit=$4
|
||||
size=$5
|
||||
factor=$6
|
||||
min=$7
|
||||
max=$8
|
||||
default=$9
|
||||
mode=$10
|
||||
|
||||
gsub("\"", "", title)
|
||||
gsub("\"", "", info)
|
||||
gsub("\"", "", unit)
|
||||
|
||||
if (mode != "R")
|
||||
printf(" <channel id=\"%s\" typeId=\"type-%s\"/>\n", id, id)
|
||||
}
|
||||
END{
|
||||
print " </channels>"
|
||||
print "</channel-group-type>"
|
||||
}
|
||||
Reference in New Issue
Block a user