public static Switch ToConfigSwitch(this clsUnit unit) { Switch ret = new Switch(); ret.name = Global.mqtt_discovery_name_prefix + unit.Name; ret.state_topic = unit.ToTopic(Topic.state); ret.command_topic = unit.ToTopic(Topic.command); return(ret); }
private void PublishUnitState(clsUnit unit) { MqttClient.PublishAsync(unit.ToTopic(Topic.state), unit.ToState(), MqttQualityOfServiceLevel.AtMostOnce, true); if (unit.Number < 385) { MqttClient.PublishAsync(unit.ToTopic(Topic.brightness_state), unit.ToBrightnessState().ToString(), MqttQualityOfServiceLevel.AtMostOnce, true); } }
private void PublishUnitState(clsUnit unit) { PublishAsync(unit.ToTopic(Topic.state), unit.ToState()); if (unit.Number < 385) { PublishAsync(unit.ToTopic(Topic.brightness_state), unit.ToBrightnessState().ToString()); } }
public static Switch ToConfigSwitch(this clsUnit unit) { Switch ret = new Switch(); ret.unique_id = $"{Global.mqtt_prefix}unit{unit.Number.ToString()}switch"; ret.name = Global.mqtt_discovery_name_prefix + unit.Name; ret.state_topic = unit.ToTopic(Topic.state); ret.command_topic = unit.ToTopic(Topic.command); return(ret); }
public static Light ToConfig(this clsUnit unit) { Light ret = new Light(); ret.name = Global.mqtt_discovery_name_prefix + unit.Name; ret.state_topic = unit.ToTopic(Topic.state); ret.command_topic = unit.ToTopic(Topic.command); ret.brightness_state_topic = unit.ToTopic(Topic.brightness_state); ret.brightness_command_topic = unit.ToTopic(Topic.brightness_command); return(ret); }
public static Light ToConfig(this clsUnit unit) { Light ret = new Light(); ret.unique_id = $"{Global.mqtt_prefix}unit{unit.Number.ToString()}light"; ret.name = Global.mqtt_discovery_name_prefix + unit.Name; ret.state_topic = unit.ToTopic(Topic.state); ret.command_topic = unit.ToTopic(Topic.command); ret.brightness_state_topic = unit.ToTopic(Topic.brightness_state); ret.brightness_command_topic = unit.ToTopic(Topic.brightness_command); return(ret); }
private void PublishUnits() { log.Debug("Publishing {type}", "units"); for (ushort i = 1; i <= OmniLink.Controller.Units.Count; i++) { clsUnit unit = OmniLink.Controller.Units[i]; if (unit.DefaultProperties == true) { PublishAsync(unit.ToTopic(Topic.name), null); } else { PublishUnitState(unit); PublishAsync(unit.ToTopic(Topic.name), unit.Name); } if (unit.DefaultProperties == true || Global.mqtt_discovery_ignore_units.Contains(unit.Number)) { string type = i < 385 ? "light" : "switch"; PublishAsync($"{Global.mqtt_discovery_prefix}/{type}/{Global.mqtt_prefix}/unit{i}/config", null); continue; } if (i < 385) { PublishAsync($"{Global.mqtt_discovery_prefix}/light/{Global.mqtt_prefix}/unit{i}/config", JsonConvert.SerializeObject(unit.ToConfig())); } else { PublishAsync($"{Global.mqtt_discovery_prefix}/switch/{Global.mqtt_prefix}/unit{i}/config", JsonConvert.SerializeObject(unit.ToConfigSwitch())); } } }