Map<String, dynamic> toJson() { final mqttTopic = this.mqttTopic; final payload = this.payload; return { 'mqttTopic': mqttTopic, if (payload != null) 'payload': payload, }; }