private static string CreateItemsLine(channel channel, channelType channelType) { string icon = string.Empty; if (channelType.itemtype == "Switch") { icon = " <switch>"; } else if (channelType.category == "temperature") { icon = " <temperature>"; } return(string.Format(@"{0} {1} ""{2}""{3} {{channel=""openthermgateway:otgw:1:{4}}}", channelType.itemtype, channelType.label.ToPascalCase(), CreateLabel(channelType), icon, channel.id)); }
private static string CreateSitemapsLine(channel channel, channelType channelType) { string itemType = "Text"; string additionalValues = string.Empty; if (channelType.itemtype == "Switch") { itemType = "Switch"; } else if (!channelType.state.readOnly && channelType.category == "temperature") { itemType = "Setpoint"; } if (!channelType.state.readOnly) { if (channelType.state.minSpecified) { additionalValues += string.Format(@" minValue=""{0}""", channelType.state.min.ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (channelType.state.maxSpecified) { additionalValues += string.Format(@" maxValue=""{0}""", channelType.state.max.ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (channelType.state.stepSpecified) { additionalValues += string.Format(@" step=""{0}""", channelType.state.step.ToString(System.Globalization.CultureInfo.InvariantCulture)); } } string icon = string.Empty; if (channelType.itemtype == "Switch") { icon = "switch"; } else if (channelType.category == "temperature") { icon = "temperature"; } return(string.Format(@" {0} item=""{1}"" icon=""{2}"" label=""{3}""{4}", itemType, channelType.label.ToPascalCase(), icon, CreateLabel(channelType), additionalValues)); }
private static string CreateLabel(channelType channelType) { return(string.IsNullOrEmpty(channelType.state.pattern) ? channelType.label : channelType.label + " [" + channelType.state.pattern + "]"); }