private void PublishZones() { log.Debug("Publishing {type}", "zones"); for (ushort i = 1; i <= OmniLink.Controller.Zones.Count; i++) { clsZone zone = OmniLink.Controller.Zones[i]; if (zone.DefaultProperties == true) { PublishAsync(zone.ToTopic(Topic.name), null); } else { PublishZoneState(zone); PublishAsync(zone.ToTopic(Topic.name), zone.Name); } if (zone.DefaultProperties == true || Global.mqtt_discovery_ignore_zones.Contains(zone.Number)) { PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config", null); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config", null); continue; } PublishAsync($"{Global.mqtt_discovery_prefix}/binary_sensor/{Global.mqtt_prefix}/zone{i}/config", JsonConvert.SerializeObject(zone.ToConfig())); PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}/config", JsonConvert.SerializeObject(zone.ToConfigSensor())); PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/zone{i}/config", JsonConvert.SerializeObject(zone.ToConfigSwitch())); if (zone.IsTemperatureZone()) { PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}temp/config", JsonConvert.SerializeObject(zone.ToConfigTemp(OmniLink.Controller.TempFormat))); } else if (zone.IsHumidityZone()) { PublishAsync($"{Global.mqtt_discovery_prefix}/sensor/{Global.mqtt_prefix}/zone{i}humidity/config", JsonConvert.SerializeObject(zone.ToConfigHumidity())); } } }